mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-08 00:02:46 -04:00
Merge pull request #155 from stripe/fix-connection-error-message
Better error message for ServerBrokeConnection exception
This commit is contained in:
commit
afd42ecd41
@ -259,26 +259,31 @@ module Stripe
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.handle_restclient_error(e)
|
def self.handle_restclient_error(e)
|
||||||
case e
|
connection_message = "Please check your internet connection and try again. " \
|
||||||
when RestClient::ServerBrokeConnection, RestClient::RequestTimeout
|
"If this problem persists, you should check Stripe's service status at " \
|
||||||
message = "Could not connect to Stripe (#{@api_base}). " +
|
|
||||||
"Please check your internet connection and try again. " +
|
|
||||||
"If this problem persists, you should check Stripe's service status at " +
|
|
||||||
"https://twitter.com/stripestatus, or let us know at support@stripe.com."
|
"https://twitter.com/stripestatus, or let us know at support@stripe.com."
|
||||||
|
|
||||||
|
case e
|
||||||
|
when RestClient::RequestTimeout
|
||||||
|
message = "Could not connect to Stripe (#{@api_base}). #{connection_message}"
|
||||||
|
|
||||||
|
when RestClient::ServerBrokeConnection
|
||||||
|
message = "The connection to the server (#{@api_base}) broke before the " \
|
||||||
|
"request completed. #{connection_message}"
|
||||||
|
|
||||||
when RestClient::SSLCertificateNotVerified
|
when RestClient::SSLCertificateNotVerified
|
||||||
message = "Could not verify Stripe's SSL certificate. " +
|
message = "Could not verify Stripe's SSL certificate. " \
|
||||||
"Please make sure that your network is not intercepting certificates. " +
|
"Please make sure that your network is not intercepting certificates. " \
|
||||||
"(Try going to https://api.stripe.com/v1 in your browser.) " +
|
"(Try going to https://api.stripe.com/v1 in your browser.) " \
|
||||||
"If this problem persists, let us know at support@stripe.com."
|
"If this problem persists, let us know at support@stripe.com."
|
||||||
|
|
||||||
when SocketError
|
when SocketError
|
||||||
message = "Unexpected error communicating when trying to connect to Stripe. " +
|
message = "Unexpected error communicating when trying to connect to Stripe. " \
|
||||||
"You may be seeing this message because your DNS is not working. " +
|
"You may be seeing this message because your DNS is not working. " \
|
||||||
"To check, try running 'host stripe.com' from the command line."
|
"To check, try running 'host stripe.com' from the command line."
|
||||||
|
|
||||||
else
|
else
|
||||||
message = "Unexpected error communicating with Stripe. " +
|
message = "Unexpected error communicating with Stripe. " \
|
||||||
"If this problem persists, let us know at support@stripe.com."
|
"If this problem persists, let us know at support@stripe.com."
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user