Exception: Shift::Api::Core::Errors::ServerError
- Defined in:
- lib/shift/api/core/errors.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from ApiError
Instance Method Summary collapse
-
#backtrace ⇒ Object
Prepend API backtrace to the backtrace from the gem.
-
#message ⇒ Object
Replace message with more useful error from the API.
Methods inherited from ApiError
from_jsonapi_client, #initialize
Constructor Details
This class inherits a constructor from Shift::Api::Core::Errors::ApiError
Instance Method Details
#backtrace ⇒ Object
Prepend API backtrace to the backtrace from the gem
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/shift/api/core/errors.rb', line 49 def backtrace original_backtrace = super return nil if original_backtrace.nil? api_errors = env.response.body["errors"] return original_backtrace if api_errors.nil? api_backtrace = api_errors[0].dig("meta", "backtrace") return original_backtrace if api_backtrace.nil? api_backtrace.map { |entry| "/<shift_api>#{entry}" }.concat(original_backtrace) end |
#message ⇒ Object
Replace message with more useful error from the API
38 39 40 41 42 43 44 45 46 |
# File 'lib/shift/api/core/errors.rb', line 38 def = "Internal Server Error\n#{env.response.body}" api_errors = env.response.body["errors"] return if api_errors.nil? api_exception = api_errors[0].dig("meta", "exception") api_exception ? api_exception : end |