Exception: ManagementAPIV2::Exception
- Inherits:
-
StandardError
- Object
- StandardError
- ManagementAPIV2::Exception
- Defined in:
- app/services/management_api_v2/exception.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(response_or_ex = "External services error") ⇒ Exception
constructor
A new instance of Exception.
Constructor Details
#initialize(response_or_ex = "External services error") ⇒ Exception
Returns a new instance of Exception.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/management_api_v2/exception.rb', line 7 def initialize(response_or_ex="External services error") @status = 503 if response_or_ex.respond_to?(:body) @status = 422 body = response_or_ex.body || {} if body.fetch("error", false) super body.fetch("error") elsif body.fetch("errors", false) super Array(body.fetch("errors")).first else super response_or_ex.body end else super response_or_ex end end |
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'app/services/management_api_v2/exception.rb', line 5 def status @status end |