On 01/ 8/10 09:59 AM, John Rice wrote:
Hi - this adds a Transport exception handler when getting pkg list data
from the api.

I also uses logging in a number of Transport exception handlers in the
GUI where we formerly reported them to the user. This was resulting in
over reporting of transient transport errors in a number of places, in
particular when performing some long running searches.

http://cr.opensolaris.org/~jmr/pm_13736_transport_exception_8Jan_350pm/

Okay, so something that's concerned me for a while here is that the error handling generally used in PM isn't quite right.

The pattern for exception handling should be something like:

try:
    api_call()
except SpecificException1, ex:
    # Handle specific exception case 1 that requires special handling.

except SpecificException2, ex:
    # Handle specific exception case 2 that requires special handling.

except Exception, ex:
    # Handle all remaining exceptions generically.

In this particular case, I would change line 4630 of src/packagemanager.py to handle Exception, not TransportError. Alternatively, if you want to handle ApiExceptions separately from generic exceptions, then catch ApiException and Exception both.

Otherwise, when the next failure case arises, this code is just going to break again. There only guarantee about what exceptions API calls can raise are that they should always be an instance of ApiException.

src/packagemanager.py:
  line 2542: missing ', ex' here needed by line 2543

--
Shawn Walker
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to