braintree / braintree_dotnet

Braintree .NET library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
136 stars 73 forks source link

How to handle DownForMaintenance exceptions #92

Closed Fraaankes closed 4 years ago

Fraaankes commented 4 years ago

General information

Issue description

We are seeing some of these exceptions during your "maintenance windows":

Braintree.Exceptions.DownForMaintenanceException: Exception of type 'Braintree.Exceptions.DownForMaintenanceException' was thrown.
  at Braintree.HttpService.ThrowExceptionIfErrorStatusCode(HttpStatusCode httpStatusCode, String message)
  at Braintree.HttpService.<GetHttpResponseAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
  at Braintree.BraintreeService.<GetXmlResponseAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
  at Braintree.CustomerGateway.<FindAsync>d__5.MoveNext()

But here it says it should never happen anymore: https://developers.braintreepayments.com/reference/general/exceptions/dotnet#down-for-maintenance

But it doesnt mention how a merchant should handle the exception. Since you are technically down, should the request just be abandoned ?

hollabaq86 commented 4 years ago

👋 @Fraaankes, thanks for reaching out. As our documentation states, we have to keep the name for this exception DownForMaintenance to maintain backwards compatibility. We'll change the name when we make a major version update. This kind of exception is thrown for HTTP Status ServiceUnavailable or a 503.

This type of response doesn't necessarily mean that we are down, but that our API was unavailable at the time of your request. You could retry the same request to see if you receive a successful response.

If you ever do encounter a period of 503 responses from Braintree, you absolutely should contact Support with timestamps and the type of API calls you are making so that we can investigate. Additionally, I recommend subscribing to our Status Site so that you are made aware of any issues.

I'll leave feedback with our docs team to make this more clear in the section you referenced.