Exception: GH::Error
- Inherits:
-
StandardError
- Object
- StandardError
- GH::Error
- Defined in:
- lib/gh/error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
Returns the value of attribute info.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(error = nil, payload = nil, info = {}) ⇒ Error
constructor
A new instance of Error.
- #message ⇒ Object
- #payload ⇒ Object
Constructor Details
#initialize(error = nil, payload = nil, info = {}) ⇒ Error
Returns a new instance of Error.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
5 6 7 |
# File 'lib/gh/error.rb', line 5 def info @info end |
Instance Method Details
#error ⇒ Object
35 36 37 |
# File 'lib/gh/error.rb', line 35 def error info[:error] end |
#message ⇒ Object
39 40 41 |
# File 'lib/gh/error.rb', line 39 def "GH request failed\n" + info.map { |k,v| entry(k,v) }.join("\n") end |
#payload ⇒ Object
31 32 33 |
# File 'lib/gh/error.rb', line 31 def payload info[:payload] end |