Exception: Credly::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Credly::Error
- Defined in:
- lib/credly-ruby/error.rb
Direct Known Subclasses
BadRequest, ClientError, Forbidden, Gone, InternalServerError, NotFound, ServerError, ServiceUnavailable, Unauthorized, UnprocessableEntity
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
-
.from_response(response) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength:.
Instance Method Summary collapse
-
#initialize(response = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response = nil) ⇒ Error
Returns a new instance of Error.
25 26 27 28 29 |
# File 'lib/credly-ruby/error.rb', line 25 def initialize(response = nil) @response = response super() end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/credly-ruby/error.rb', line 5 def response @response end |
Class Method Details
.from_response(response) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength:
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/credly-ruby/error.rb', line 7 def self.from_response(response) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength: klass = case response.status when 400 then BadRequest when 401 then Unauthorized when 403 then Forbidden when 404 then NotFound when 410 then Gone when 422 then UnprocessableEntity when 400..499 then ClientError when 500 then InternalServerError when 503 then ServiceUnavailable when 500..599 then ServerError end klass&.new(response) end |