Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Corrected the __str__ method on the standard exceptions to actually s…

…how an error message. Should be a lot more useful for debugging now.
  • Loading branch information...
commit 4ab375a0ccf92480ae875ea4efacf2e90b10c265 1 parent fe80b1c
@gtaylor gtaylor authored committed
Showing with 17 additions and 5 deletions.
  1. +16 −4 paypal/exceptions.py
  2. +1 −1  paypal/interface.py
View
20 paypal/exceptions.py
@@ -7,11 +7,15 @@ class PayPalError(Exception):
"""
Used to denote some kind of generic error.
"""
- def __init__(self, message):
- self.message = message
+ def __init__(self, message, error_code=None):
+ self.response = message
+ self.error_code = error_code
def __str__(self):
- return repr(self.message)
+ if self.error_code:
+ return "%s (Error Code: %s)" % (repr(self.message), self.error_code)
+ else:
+ return repr(self.message)
class PayPalConfigError(PayPalError):
@@ -24,5 +28,13 @@ class PayPalConfigError(PayPalError):
class PayPalAPIResponseError(PayPalError):
"""
Raised when there is an error coming back with a PayPal NVP API response.
+
+ Pipe the error message from the API to the exception, along with
+ the error code.
"""
- pass
+ def __init__(self, response):
+ self.response = response
+ self.error_code = response.L_ERRORCODE0
+ self.message = response.L_LONGMESSAGE0
+ self.short_message = response.L_SHORTMESSAGE0
+ self.correlation_id = response.CORRELATIONID
View
2  paypal/interface.py
@@ -137,7 +137,7 @@ def address_verify(self, email, street, zip):
Postal code to verify.
To pass verification, the value of Zip mustmatch the first five
- single-byte characters of the postal code ofthe verified postal
+ single-byte characters of the postal code of the verified postal
address for the verified PayPal member.
Maximumstring length: 16 single-byte characters.
Please sign in to comment.
Something went wrong with that request. Please try again.