Exception: GrowthPush::Exception
- Inherits:
-
StandardError
- Object
- StandardError
- GrowthPush::Exception
- Defined in:
- lib/growth_push/exception.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status, code, message) ⇒ Exception
constructor
A new instance of Exception.
Constructor Details
#initialize(status, code, message) ⇒ Exception
Returns a new instance of Exception.
29 30 31 32 33 |
# File 'lib/growth_push/exception.rb', line 29 def initialize(status, code, ) @status = status @code = code super end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/growth_push/exception.rb', line 3 def code @code end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/growth_push/exception.rb', line 3 def status @status end |
Class Method Details
.handle_response(response) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/growth_push/exception.rb', line 6 def handle_response(response) klass = klass_for_status(response.code.to_i) exception = if klass klass.new(response.code, response.) else Exception.new(response.code.to_i, response.code, response.) end end |
.klass_for_status(status) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/growth_push/exception.rb', line 15 def klass_for_status(status) case status when 400 BadRequest when 401 Unauthorized when 404 NotFound when 500 InternalServerError end end |