braintree / braintree_python

Braintree Python library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
242 stars 115 forks source link

exceptions need a common base class #3

Closed foresto closed 14 years ago

foresto commented 14 years ago

All the exceptions in the braintree package derive directly from Exception, which makes them indistinguishable from standard python exceptions unless I write special cases for each one of them (and hope new ones never show up). For example:

try:
    braintree.Customer.create( dict( first_name="John", last_name="Doe"))
except (AuthenticationError, 
    AuthorizationError, 
    DownForMaintenanceError,
    ForgedQueryStringError,
    NotFoundError,
    ServerError,
    UnexpectedError,
    UpgradeRequiredError):
    print "braintree raised an exception"

All these exception classes really need a common ancestor that doesn't belong to the python standard library. braintree.Error, perhaps.

braintreeps commented 14 years ago

Thanks for the suggestion. We added a common exception ancestor which will be released in the next version. If you would like to be notified when we release, please sign up at http://www.braintreepaymentsolutions.com/gateway/gateway-updates