Exception: RubyLokaliseApi::Error
- Inherits:
-
StandardError
- Object
- StandardError
- RubyLokaliseApi::Error
- Defined in:
- lib/ruby_lokalise_api/error.rb
Overview
Standard API errors
Constant Summary collapse
- ClientError =
Class.new(self)
- ServerError =
Class.new(self)
- BadRequest =
Class.new(ClientError)
Class.new(ClientError)
- NotAcceptable =
Class.new(ClientError)
- NotFound =
Class.new(ClientError)
- Conflict =
Class.new(ClientError)
- TooManyRequests =
Class.new(ClientError)
- Forbidden =
Class.new(ClientError)
- Locked =
Class.new(ClientError)
- MethodNotAllowed =
Class.new(ClientError)
- NotImplemented =
Class.new(ServerError)
- BadGateway =
Class.new(ServerError)
Class.new(ServerError)
- GatewayTimeout =
Class.new(ServerError)
- ERRORS =
{ 400 => RubyLokaliseApi::Error::BadRequest, 401 => RubyLokaliseApi::Error::Unauthorized, 403 => RubyLokaliseApi::Error::Forbidden, 404 => RubyLokaliseApi::Error::NotFound, 405 => RubyLokaliseApi::Error::MethodNotAllowed, 406 => RubyLokaliseApi::Error::NotAcceptable, 409 => RubyLokaliseApi::Error::Conflict, 423 => RubyLokaliseApi::Error::Locked, 429 => RubyLokaliseApi::Error::TooManyRequests, 500 => RubyLokaliseApi::Error::ServerError, 502 => RubyLokaliseApi::Error::BadGateway, 503 => RubyLokaliseApi::Error::ServiceUnavailable, 504 => RubyLokaliseApi::Error::GatewayTimeout }.freeze
Class Method Summary collapse
-
.from_response(body) ⇒ Object
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message = '') ⇒ Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message = '') ⇒ Error
Initializes a new Error object
54 55 56 |
# File 'lib/ruby_lokalise_api/error.rb', line 54 def initialize( = '') super end |
Class Method Details
.from_response(body) ⇒ Object
Create a new error from an HTTP response
42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby_lokalise_api/error.rb', line 42 def from_response(body) msg = if body.respond_to?(:key) body.key?('error') ? body['error']['message'] : body['message'] else body end new msg.to_s end |