Exception: Teamsupport::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Teamsupport::Error
- Defined in:
- lib/teamsupport/error.rb
Overview
Custom error class for rescuing from all Teamsupport errors
Constant Summary collapse
- ClientError =
Raised when Teamsupport returns a 4xx HTTP status code
Class.new(self)
- BadRequest =
Raised when Teamsupport returns the HTTP status code 400
Class.new(ClientError)
Class.new(ClientError)
- Forbidden =
Raised when Teamsupport returns the HTTP status code 403
Class.new(ClientError)
- NotFound =
Raised when Teamsupport returns the HTTP status code 404
Class.new(ClientError)
- NotAcceptable =
Raised when Teamsupport returns the HTTP status code 406
Class.new(ClientError)
- UnprocessableEntity =
Raised when Teamsupport returns the HTTP status code 422
Class.new(ClientError)
- TooManyRequests =
Raised when Teamsupport returns the HTTP status code 429
Class.new(ClientError)
- ServerError =
Raised when Teamsupport returns a 5xx HTTP status code
Class.new(self)
- InternalServerError =
Raised when Teamsupport returns the HTTP status code 500
Class.new(ServerError)
- BadGateway =
Raised when Teamsupport returns the HTTP status code 502
Class.new(ServerError)
Class.new(ServerError)
- GatewayTimeout =
Raised when Teamsupport returns the HTTP status code 504
Class.new(ServerError)
- ERRORS =
{ 400 => Teamsupport::Error::BadRequest, 401 => Teamsupport::Error::, 403 => Teamsupport::Error::Forbidden, 404 => Teamsupport::Error::NotFound, 406 => Teamsupport::Error::NotAcceptable, 422 => Teamsupport::Error::UnprocessableEntity, 429 => Teamsupport::Error::TooManyRequests, 500 => Teamsupport::Error::InternalServerError, 502 => Teamsupport::Error::BadGateway, 503 => Teamsupport::Error::ServiceUnavailable, 504 => Teamsupport::Error::GatewayTimeout, }.freeze
Instance Attribute Summary collapse
-
#code ⇒ Integer
readonly
Provide a code method for reading HTTP status code from Error.
Class Method Summary collapse
-
.from_response(body, _headers) ⇒ Teamsupport::Error
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message = '', code = nil) ⇒ Teamsupport::Error
constructor
private
Initializes a new Error object.
Constructor Details
#initialize(message = '', code = nil) ⇒ Teamsupport::Error
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a new Error object
130 131 132 133 |
# File 'lib/teamsupport/error.rb', line 130 def initialize( = '', code = nil) super() @code = code end |
Instance Attribute Details
#code ⇒ Integer (readonly)
Provide a code method for reading HTTP status code from Error
13 14 15 |
# File 'lib/teamsupport/error.rb', line 13 def code @code end |
Class Method Details
.from_response(body, _headers) ⇒ Teamsupport::Error
Create a new error from an HTTP response
81 82 83 84 |
# File 'lib/teamsupport/error.rb', line 81 def from_response(body, _headers) , code = parse_error(body) new(, code) end |