Exception: Masklen::Error

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

Overview

Raised when the API returns a non-2xx response or when a network error occurs.

Attributes:

status_code    - HTTP status code returned by the server (Integer)
error_code     - machine-readable error code from the API response body (String)
error_message  - human-readable description from the API response body (String)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code:, error_code:, error_message:) ⇒ Error

Returns a new instance of Error.



11
12
13
14
15
16
# File 'lib/masklen/error.rb', line 11

def initialize(status_code:, error_code:, error_message:)
  @status_code   = status_code
  @error_code    = error_code
  @error_message = error_message
  super("Masklen API error #{status_code} (#{error_code}): #{error_message}")
end

Instance Attribute Details

#error_codeObject (readonly)

Returns the value of attribute error_code.



9
10
11
# File 'lib/masklen/error.rb', line 9

def error_code
  @error_code
end

#error_messageObject (readonly)

Returns the value of attribute error_message.



9
10
11
# File 'lib/masklen/error.rb', line 9

def error_message
  @error_message
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



9
10
11
# File 'lib/masklen/error.rb', line 9

def status_code
  @status_code
end