Add logger error messages for Stripe errors

This commit is contained in:
M.Ravi 2017-10-02 01:35:28 +02:00
parent 42224a5d38
commit b848841337

View file

@ -28,28 +28,34 @@ def handleStripeError(f):
body = e.json_body body = e.json_body
err = body['error'] err = body['error']
response.update({'error': err['message']}) response.update({'error': err['message']})
logger.error(str(e))
return response return response
except stripe.error.RateLimitError as e: except stripe.error.RateLimitError as e:
response.update( response.update(
{'error': "Too many requests made to the API too quickly"}) {'error': "Too many requests made to the API too quickly"})
return response return response
except stripe.error.InvalidRequestError as e: except stripe.error.InvalidRequestError as e:
logger.error(str(e))
response.update({'error': "Invalid parameters"}) response.update({'error': "Invalid parameters"})
return response return response
except stripe.error.AuthenticationError as e: except stripe.error.AuthenticationError as e:
# Authentication with Stripe's API failed # Authentication with Stripe's API failed
# (maybe you changed API keys recently) # (maybe you changed API keys recently)
logger.error(str(e))
response.update({'error': common_message}) response.update({'error': common_message})
return response return response
except stripe.error.APIConnectionError as e: except stripe.error.APIConnectionError as e:
logger.error(str(e))
response.update({'error': common_message}) response.update({'error': common_message})
return response return response
except stripe.error.StripeError as e: except stripe.error.StripeError as e:
# maybe send email # maybe send email
logger.error(str(e))
response.update({'error': common_message}) response.update({'error': common_message})
return response return response
except Exception as e: except Exception as e:
# maybe send email # maybe send email
logger.error(str(e))
response.update({'error': common_message}) response.update({'error': common_message})
return response return response