Method: Alman::ApiMethod#compose_error

Defined in:
lib/alman/apibits/api_method.rb

#compose_error(error) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/alman/apibits/api_method.rb', line 55

def compose_error(error)
  msg = "An error occured while making the API call."

  case error
  when RestClient::ExceptionWithResponse
    return error_with_response(error)

  when RestClient::RequestTimeout
    msg = "The request timed out while making the API call."

  when RestClient::ServerBrokeConnection
    msg = "The connection to the server broke before the request completed."

  when SocketError
    msg = "An unexpected error occured while trying to connect to " \
      "the API. You may be seeing this message because your DNS is " \
      "not working. To check, try running 'host #{Alman.api_base}' "\
      "from the command line."

  else
    msg = "An unexpected error occured. If this problem persists let us " \
      "know at #{Alman.support_email}."
  end

  return ApiConnectionError.new(msg, self)
end