Exception: RestRequestor::StandardError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rest_requestor.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, verb, resp, params = {}, msg: nil) ⇒ StandardError

Returns a new instance of StandardError.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rest_requestor.rb', line 12

def initialize(uri, verb, resp, params = {}, msg: nil)
  body = if resp["Content-Type"]&.include?("text/html")
    if (m = resp.body.to_s.match(/<title>(.*)<\/title>/))
      m[1]
    else
      resp.body.to_s[0..20]
    end
  else
    resp.body.to_s
  end
  msg ||= "uri: #{uri}, Verb: #{verb}, Resp: #{resp.code} - #{resp.message}, Body: #{body}, Params: #{params}"
  super(msg)
end