class GH::Error
Attributes
info[R]
Public Class Methods
new(error = nil, payload = nil, info = {})
click to toggle source
# File lib/gh/error.rb, line 7 def initialize(error = nil, payload = nil, info = {}) info = info.merge(error.info) if error.respond_to? :info and Hash === error.info error = error.error while error.respond_to? :error @info = info.merge(:error => error, :payload => payload) if error set_backtrace error.backtrace if error.respond_to? :backtrace if error.respond_to? :response and error.response case response = error.response when Hash @info[:response_status] = response[:status] @info[:response_headers] = response[:headers] @info[:response_body] = response[:body] when Faraday::Response @info[:response_status] = response.status @info[:response_headers] = response.headers @info[:response_body] = response.body else @info[:response] = response end end end end
Public Instance Methods
error()
click to toggle source
# File lib/gh/error.rb, line 35 def error info[:error] end
message()
click to toggle source
# File lib/gh/error.rb, line 39 def message "GH request failed\n" + info.map { |k,v| entry(k,v) }.join("\n") end
payload()
click to toggle source
# File lib/gh/error.rb, line 31 def payload info[:payload] end
Private Instance Methods
entry(key, value)
click to toggle source
# File lib/gh/error.rb, line 45 def entry(key, value) value = "#{value.class}: #{value.message}" if Exception === value value = value.inspect unless String === value value.gsub!(/"Basic .+"|(client_(?:id|secret)=)[^&\s]+/, '\1[removed]') (key.to_s + ": ").ljust(20) + value end