Exception: Webhookdb::Http::Error

Inherits:
BaseError
  • Object
show all
Defined in:
lib/webhookdb/http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, msg = nil) ⇒ Error

Returns a new instance of Error.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/webhookdb/http.rb', line 19

def initialize(response, msg=nil)
  @response = response
  @body = response.body
  @headers = response.headers.to_h
  @status = response.code
  @uri = response.request.last_uri.dup
  if @uri.query.present?
    cleaned_params = CGI.parse(@uri.query).map { |k, v| k.include?("secret") ? [k, ".snip."] : [k, v] }
    @uri.query = HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER.call(cleaned_params)
  end
  @http_method = response.request.http_method::METHOD
  super(msg || self.to_s)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



17
18
19
# File 'lib/webhookdb/http.rb', line 17

def body
  @body
end

#http_methodObject (readonly)

Returns the value of attribute http_method.



17
18
19
# File 'lib/webhookdb/http.rb', line 17

def http_method
  @http_method
end

#responseObject (readonly)

Returns the value of attribute response.



17
18
19
# File 'lib/webhookdb/http.rb', line 17

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



17
18
19
# File 'lib/webhookdb/http.rb', line 17

def status
  @status
end

#uriObject (readonly)

Returns the value of attribute uri.



17
18
19
# File 'lib/webhookdb/http.rb', line 17

def uri
  @uri
end

Instance Method Details

#to_sObject Also known as: inspect



33
34
35
# File 'lib/webhookdb/http.rb', line 33

def to_s
  return "HttpError(status: #{self.status}, method: #{self.http_method}, uri: #{self.uri}, body: #{self.body})"
end