Exception: RTS::Error
- Inherits:
-
StandardError
- Object
- StandardError
- RTS::Error
- Defined in:
- lib/rts/error.rb
Constant Summary collapse
- ClientError =
Raised when Rts returns a 4xx HTTP status code
Class.new(self)
- BadRequest =
Raised when Rts returns the HTTP status code 400
Class.new(ClientError)
- NotFound =
Raised when Rts returns the HTTP status code 404
Class.new(ClientError)
- Unknown =
Raised when Rts returns unknown status code
Class.new(self)
Class Method Summary collapse
Class Method Details
.errors ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rts/error.rb', line 6 def errors @errors ||= { 400 => RTS::Error::BadRequest, 404 => RTS::Error::NotFound } end |
.on_complete(response) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rts/error.rb', line 13 def on_complete(response) klass = errors[response.http_code&.to_i] || RTS::Error::Unknown request = response.response&.request.inspect raise klass.new({ code: response.http_code, body: response.http_body, request: request }) end |