Exception: ShelfWatch::Error

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

Overview

Base exception for all ShelfWatch SDK errors.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code: nil, body: nil) ⇒ Error

Returns a new instance of Error.



8
9
10
11
12
13
# File 'lib/shelfwatch/errors.rb', line 8

def initialize(message, status_code: nil, body: nil)
  @message = message
  @status_code = status_code
  @body = body
  super(to_s)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/shelfwatch/errors.rb', line 6

def body
  @body
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/shelfwatch/errors.rb', line 6

def message
  @message
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



6
7
8
# File 'lib/shelfwatch/errors.rb', line 6

def status_code
  @status_code
end

Instance Method Details

#to_sObject



15
16
17
18
19
20
21
# File 'lib/shelfwatch/errors.rb', line 15

def to_s
  if status_code
    "[#{status_code}] #{message}"
  else
    message.to_s
  end
end