Exception: Posthubify::Error

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

Overview

Raised when an API request returns a non-2xx status.

begin
  ph.posts.get("missing")
rescue Posthubify::Error => e
  puts [e.status, e.code, e.message].inspect
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, message, code = nil, body = nil) ⇒ Error

Returns a new instance of Error.



14
15
16
17
18
19
# File 'lib/posthubify/errors.rb', line 14

def initialize(status, message, code = nil, body = nil)
  super(message)
  @status = status
  @code = code
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



12
13
14
# File 'lib/posthubify/errors.rb', line 12

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



12
13
14
# File 'lib/posthubify/errors.rb', line 12

def code
  @code
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/posthubify/errors.rb', line 12

def status
  @status
end