Exception: Ohmage::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Ohmage::Error
- Defined in:
- lib/ohmage/error.rb
Constant Summary collapse
- ClientError =
Class.new(self)
- BadRequest =
Class.new(ClientError)
Class.new(ClientError)
- NotFound =
Class.new(ClientError)
- NotAcceptable =
Class.new(ClientError)
- InvalidToken =
Class.new(ClientError)
- InvalidParameter =
Class.new(ClientError)
- MobilityException =
Class.new(ClientError)
- SurveyException =
Class.new(ClientError)
- CampaignException =
Class.new(ClientError)
- ImageException =
Class.new(ClientError)
- ClassException =
Class.new(ClientError)
- UserException =
Class.new(ClientError)
- CatchAll =
Class.new(ClientError)
- ServerError =
Class.new(self)
- InternalServerError =
Class.new(ServerError)
- BadGateway =
Class.new(ServerError)
Class.new(ServerError)
- GatewayTimeout =
Class.new(ServerError)
- ERRORS =
{ 888 => Ohmage::Error::CatchAll, # just, i don't know, catch 'em all. 400 => Ohmage::Error::BadRequest, 401 => Ohmage::Error::, 404 => Ohmage::Error::NotFound, 405 => Ohmage::Error::, 406 => Ohmage::Error::NotAcceptable, 500 => Ohmage::Error::InternalServerError, 502 => Ohmage::Error::BadGateway, 503 => Ohmage::Error::ServiceUnavailable, 504 => Ohmage::Error::GatewayTimeout, }
- STRING_ERRORS =
How ugly is this??
{ '0100' => Ohmage::Error::InternalServerError, '0101' => Ohmage::Error::InternalServerError, # Auth '0200' => Ohmage::Error::, '0201' => Ohmage::Error::, '0202' => Ohmage::Error::, '0203' => Ohmage::Error::InvalidToken, }
Class Method Summary collapse
-
.from_response(body) ⇒ Ohmage::Error
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message = '', code = nil) ⇒ Ohmage::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message = '', code = nil) ⇒ Ohmage::Error
Initializes a new Error object
106 107 108 109 |
# File 'lib/ohmage/error.rb', line 106 def initialize( = '', code = nil) super() @code = code end |
Class Method Details
.from_response(body) ⇒ Ohmage::Error
Create a new error from an HTTP response
75 76 77 78 79 80 81 82 83 |
# File 'lib/ohmage/error.rb', line 75 def from_response(body) , code = parse_error(body) # ohmage returns own error codes in body and as strings. if code.is_a? String new(, 888) else new(, code) end end |