Exception: LunaPark::Errors::Http
- Defined in:
- lib/luna_park/errors/http.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Errors::Http must contain response.
Instance Method Summary collapse
-
#details ⇒ Object
Formatted details Resource does not found Http::Error.new(request: request, something: ‘important’).details # => { # title: ‘Ping-pong’, # status: ‘OK’, # request: { # body: ‘“message”:“ping”’, # method: :post, # headers: ‘application/json’, # open_timeout: 10, # read_timeout: 10, # sent_at: nil, # url: ‘example.com/api/ping’ # }, # response: { # body: ‘“message”:“pong”’, # code: 200, # headers: ‘application/json’, # cookies: ‘dkmvc9saudj3cndsaosp’ # }, # error_details: { something: ‘important’ } # }.
-
#initialize(msg = nil, response:, notify: nil, **details) ⇒ Http
constructor
Create new error.
-
#request ⇒ Object
Return request which call this is error.
Methods inherited from Base
inherited, message, #message, notify, #notify?, #notify_lvl
Methods included from LunaPark::Extensions::Exceptions::Substitutive
Constructor Details
#initialize(msg = nil, response:, notify: nil, **details) ⇒ Http
Create new error
31 32 33 34 35 36 |
# File 'lib/luna_park/errors/http.rb', line 31 def initialize(msg = nil, response:, notify: nil, **details) raise ArgumentError, 'Response should be Http::Response' unless response.is_a? LunaPark::Http::Response @response = response super msg, notify: notify, **details end |
Instance Attribute Details
#response ⇒ Object (readonly)
Errors::Http must contain response
12 13 14 |
# File 'lib/luna_park/errors/http.rb', line 12 def response @response end |
Instance Method Details
#details ⇒ Object
Formatted details Resource does not found Http::Error.new(request: request, something: ‘important’).details # =>
# title: 'Ping-pong',
# status: 'OK',
# request: {
# body: '{"message":"ping"',
# method: :post,
# headers: 'application/json',
# open_timeout: 10,
# read_timeout: 10,
# sent_at: nil,
# url: 'http://example.com/api/ping'
# },
# response: {
# body: '"message":"pong"',
# code: 200,
# headers: 'application/json',
# cookies: 'dkmvc9saudj3cndsaosp'
# },
# error_details: { something: 'important' }
# }
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/luna_park/errors/http.rb', line 66 def details # rubocop:disable Metrics/MethodLength, Metrics/AbcSize { title: request.title, status: response.status, request: { method: request.method, url: request.url, open_timeout: request.open_timeout, read_timeout: request.read_timeout, sent_at: request.sent_at, headers: request.headers, body: request.body }, response: { code: response.code, headers: response.headers, cookies: response., body: response.body }, error_details: super } end |
#request ⇒ Object
Return request which call this is error.
39 40 41 |
# File 'lib/luna_park/errors/http.rb', line 39 def request response.request end |