Exception: AylienTextApi::Error
- Inherits:
-
StandardError
- Object
- StandardError
- AylienTextApi::Error
- Defined in:
- lib/aylien_text_api/error.rb
Constant Summary collapse
- ClientError =
Raised when Aylien Text API returns a 4xx HTTP status code
Class.new(self)
- InvalidInput =
Raised when Aylien Text API input is invalid
Class.new(ClientError)
- BadRequest =
Raised when Aylien Text API returns the HTTP status code 400
Class.new(ClientError)
Class.new(ClientError)
- PaymentRequired =
Raised when Aylien Text API returns the HTTP status code 402
Class.new(ClientError)
- Forbidden =
Raised when Aylien Text API returns the HTTP status code 403
Class.new(ClientError)
- NotFound =
Raised when Aylien Text API returns the HTTP status code 404
Class.new(ClientError)
- NotAcceptable =
Raised when Aylien Text API returns the HTTP status code 406
Class.new(ClientError)
- UnprocessableEntity =
Raised when Aylien Text API returns the HTTP status code 422
Class.new(ClientError)
- TooManyRequests =
Raised when Aylien Text API returns the HTTP status code 429
Class.new(ClientError)
- ServerError =
Raised when Aylien Text API returns a 5xx HTTP status code
Class.new(self)
- InternalServerError =
Raised when Aylien Text API returns the HTTP status code 500
Class.new(ServerError)
- BadGateway =
Raised when Aylien Text API returns the HTTP status code 502
Class.new(ServerError)
Class.new(ServerError)
- GatewayTimeout =
Raised when Aylien Text API returns the HTTP status code 504
Class.new(ServerError)
- ERRORS =
{ 400 => AylienTextApi::Error::BadRequest, 401 => AylienTextApi::Error::Unauthorized, 402 => AylienTextApi::Error::PaymentRequired, 403 => AylienTextApi::Error::Forbidden, 404 => AylienTextApi::Error::NotFound, 406 => AylienTextApi::Error::NotAcceptable, 422 => AylienTextApi::Error::UnprocessableEntity, 429 => AylienTextApi::Error::TooManyRequests, 500 => AylienTextApi::Error::InternalServerError, 502 => AylienTextApi::Error::BadGateway, 503 => AylienTextApi::Error::ServiceUnavailable, 504 => AylienTextApi::Error::GatewayTimeout }
Class Method Summary collapse
-
.from_response(response) ⇒ AylienTextApi::Error
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message = '') ⇒ AylienTextApi::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message = '') ⇒ AylienTextApi::Error
Initializes a new Error object
109 110 111 |
# File 'lib/aylien_text_api/error.rb', line 109 def initialize( = '') super() end |
Class Method Details
.from_response(response) ⇒ AylienTextApi::Error
Create a new error from an HTTP response
82 83 84 85 86 87 88 89 90 |
# File 'lib/aylien_text_api/error.rb', line 82 def from_response(response) body = if response["Content-Type"].include?('json') JSON.parse(response.body, :symbolize_names => true) else response.body end = parse_error(body) new() end |