Module: ErrorHandling

Defined in:
lib/simperium/error_handling.rb

Class Method Summary collapse

Class Method Details

.handle_api_error(rcode, rbody) ⇒ Object

Raises:

  • (StandardError)


15
16
17
18
# File 'lib/simperium/error_handling.rb', line 15

def self.handle_api_error(rcode, rbody)
    message = rcode.to_s + ' '+ rbody
    raise StandardError.new(message)
end

.handle_restclient_error(e) ⇒ Object

Raises:

  • (StandardError)


2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/simperium/error_handling.rb', line 2

def self.handle_restclient_error(e)
    case e
    when RestClient::ServerBrokeConnection, RestClient::RequestTimeout
      message = "Could not connect to Simperium (auth.simperium.com).  Please check your internet connection and try again.  If the problem continues, you should check Simperium's service status at https://simperium.com/, or let us know at [email protected]."
    when SocketError
      message = "Unexpected error when trying to connect to Simpierum.  HINT: You may be seeing this message because your DNS is not working.  To check, try running 'host simperium.com' from the command line."
    else
      message = "Unexpected error communicating with Simperium.  If this problem persists, let us know at [email protected]."
    end
    message += "\n\n(Network error: #{e.message})"
    raise StandardError.new(message)
end