class LunaPark::Errors::Http
Attributes
response[R]
Errors::Http
must contain response
@return LunaPark::Http::Response
Public Class Methods
new(msg = nil, response:, notify: nil, **details)
click to toggle source
Create new error
@param msg - Message text @param notify - custom notify behaviour for the current instance of error (see self.notify) @param details - additional information to notifier
@example without parameters
error = Fatalism.new error.message # => 'You cannot change your destiny' error.notify_lvl # => :error error.notify? # => true
@example with custom parameters
@error = Fatalism.new 'Forgive me Kuzma, my feet are frozen', notify: false error.message # => 'Forgive Kuzma, my feet froze' error.notify_lvl # => :error error.notify? # => false
Calls superclass method
# 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
Public Instance Methods
details()
click to toggle source
Formatted details Resource does not found @example Error details Http::Error.new(request: request, something: 'important').details # => {
# title: 'Ping-pong', # status: 'OK', # request: { # body: '{"message":"ping"}', # method: :post, # headers: {'Content-Type': 'application/json'}, # open_timeout: 10, # read_timeout: 10, # sent_at: nil, # url: 'http://example.com/api/ping' # }, # response: { # body: '{"message":"pong"}', # code: 200, # headers: {'Content-Type': 'application/json'}, # cookies: {'Secret': 'dkmvc9saudj3cndsaosp'} # }, # error_details: { something: 'important' } # }
Calls superclass method
# 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.cookies, body: response.body }, error_details: super } end
request()
click to toggle source
Return request which call this is error.
# File lib/luna_park/errors/http.rb, line 39 def request response.request end