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::Unauthorized, 404 => Ohmage::Error::NotFound, 405 => Ohmage::Error::Unauthorized, 406 => Ohmage::Error::NotAcceptable, 500 => Ohmage::Error::InternalServerError, 502 => Ohmage::Error::BadGateway, 503 => Ohmage::Error::ServiceUnavailable, 504 => Ohmage::Error::GatewayTimeout }.freeze
- STRING_ERRORS =
How ugly is this??
{ '0100' => Ohmage::Error::InternalServerError, '0101' => Ohmage::Error::InternalServerError, # Auth '0200' => Ohmage::Error::Unauthorized, '0201' => Ohmage::Error::Unauthorized, '0202' => Ohmage::Error::Unauthorized, '0203' => Ohmage::Error::InvalidToken }
Class Method Summary collapse
-
.from_response(body) ⇒ Ohmage::Error
Create a new error from an HTTP response.
-
.initialize(message = '', code = nil) ⇒ Ohmage::Error
Initializes a new Error object.
Class Method Details
.from_response(body) ⇒ Ohmage::Error
Create a new error from an HTTP response
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ohmage/error.rb', line 86 def from_response(body) , code = parse_error(body) # ohmage returns own error codes in body and as strings. if code.is_a? String # some bug in catchall already sets this? # error class really needs a refactor. new() else new(, code) end end |
.initialize(message = '', code = nil) ⇒ Ohmage::Error
Initializes a new Error object
77 78 79 80 |
# File 'lib/ohmage/error.rb', line 77 def initialize( = '', code = nil) super() @code = code end |