Am 20. April 2012 11:31 schrieb Chris Schrier <[email protected]>:
> On Fri, Apr 20, 2012 at 10:16 AM, Michael Hanselmann <[email protected]>
> wrote:
>> Both CertificateError and GanetiApiError have “Error” as a base class.
>> Why don't those client users catch “Error”?
>
> To be honest, I'm not sure why CertificateError was used in this single
> location. GanetiApiError is the standard exception raised - 9 times
> currently.
>
> Users could catch Error; however, GanetiApiError adds a "code" attribute
> which is useful for determining the exact error type. If clients catch Error
> then they must also check for the code attribute which does not seem ideal.
> I'd prefer removing the CertificateError exception in favor of raising
> GanetiApiError with the PycURL exception but I did not want to change the
> method signature.

I just realized that probably many users didn't see Error and just
catch GanetiApiError. Of course you could move the “code” attribute to
the base class. Something I'm afraid of is people having code like the
following:

try:
  …
except GanetiApiError, err:
  …
except CertificateError, err:
  …

With your patch the behaviour is no longer correct: CertificateError
will be caught as GanetiApiError. Can you please update your patch to
mention this change (“CertificateError now derives from
GanetiApiError”, etc.) in NEWS?

Michael

Reply via email to