Exception: FlexCommerceApi::Error::InternalServer

Inherits:
Base
  • Object
show all
Defined in:
lib/flex_commerce_api/error/internal_server.rb

Direct Known Subclasses

NotFound

Instance Attribute Summary

Attributes inherited from Base

#request_env, #response_env

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from FlexCommerceApi::Error::Base

Instance Method Details

#messageObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/flex_commerce_api/error/internal_server.rb', line 4

def message
  body = response_env.fetch(:body, {"errors" => []})
  error = extract_error(body)
  return "Internal server error" unless error.present?
  if error.is_a?(::Enumerable)
    title = error.fetch("title", "")
    detail = error.fetch("detail", "")
    meta = error.fetch("meta", {})
    exception = meta.fetch("exception", "")
    backtrace = meta.fetch("backtrace", [])
    event_id = meta.fetch("event_id", "")
    "Internal server error - #{title} #{detail} #{event_id} #{exception} #{backtrace}"
  else
    "Internal server error - #{error}"
  end
end

#raven_contextObject



21
22
23
24
25
26
27
# File 'lib/flex_commerce_api/error/internal_server.rb', line 21

def raven_context
  {
    extra: {
      body: response_env[:body]
    }  
  }
end