Exception: SignInService::Error
- Inherits:
-
StandardError
- Object
- StandardError
- SignInService::Error
- Defined in:
- lib/sign_in_service/error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#response_headers ⇒ Object
readonly
Returns the value of attribute response_headers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
27 28 29 30 31 32 33 |
# File 'lib/sign_in_service/error.rb', line 27 def initialize(response) @response = response @response_headers = response[:response_headers] @response_body = parsed_response_body @errors = fetch_errors super() end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/sign_in_service/error.rb', line 5 def errors @errors end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/sign_in_service/error.rb', line 5 def response @response end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
5 6 7 |
# File 'lib/sign_in_service/error.rb', line 5 def response_body @response_body end |
#response_headers ⇒ Object (readonly)
Returns the value of attribute response_headers.
5 6 7 |
# File 'lib/sign_in_service/error.rb', line 5 def response_headers @response_headers end |
Class Method Details
.from_response(response) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sign_in_service/error.rb', line 7 def self.from_response(response) status = response[:status].to_i klass = case status when 400 then BadRequest when 401 then Unauthorized when 403 then Forbidden when 404 then NotFound when 422 then UnprocessableEntity when 400..499 then ClientError when 500 then InternalServerError when 501 then NotImplemented when 502 then BadGateway when 503 then ServiceUnavailable when 500..599 then ServerError end klass&.new(response) end |