Exception: FulfilApi::Error

Inherits:
StandardError
  • Object
show all
Includes:
Notifiable
Defined in:
lib/fulfil_api/error.rb,
lib/fulfil_api/error/notifiable.rb

Overview

The Error is the base class for all FulfilApi errors, also used for generic or unexpected errors.

Raising any of them publishes an ActiveSupport::Notifications event, so an application can report the failure to its APM without rescuing every call into the gem. See Notifiable and on_error.

Defined Under Namespace

Modules: Notifiable

Constant Summary

Constants included from Notifiable

Notifiable::EVENT_NAME, Notifiable::REENTRANCY_KEY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Notifiable

#exception, #notify

Constructor Details

#initialize(message, details: nil) ⇒ Error

Returns a new instance of Error.

Parameters:

  • message (String)

    The displayable error message for the receiver.

  • details (Hash) (defaults to: nil)

    Any additional details exposed by the issuer of the exception.



17
18
19
20
# File 'lib/fulfil_api/error.rb', line 17

def initialize(message, details: nil)
  @details = details
  super(message)
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



13
14
15
# File 'lib/fulfil_api/error.rb', line 13

def details
  @details
end

Instance Method Details

#messageString

Returns:

  • (String)


23
24
25
26
27
28
# File 'lib/fulfil_api/error.rb', line 23

def message
  body_message = parsed_body_message
  return "[FulfilApi::Error] #{body_message}" if body_message

  "[FulfilApi::Error] #{super}"
end