Exception: Baseh::BasehError

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

Overview

Error raised by every baseH failure path. #code is one of the spec error codes (spec sections 12, 13 and 18).

Constant Summary collapse

CODES =
%w[
  INVALID_PROFILE
  OUT_OF_RANGE
  PERMUTATION_FAILURE
  INVALID_LENGTH
  INVALID_CHARACTER
  INVALID_CHECKSUM
  AMBIGUOUS_INPUT
  TOO_MANY_CANDIDATES
  BLOCKED_CODE
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, message, safe_for_customer: true) ⇒ BasehError

Returns a new instance of BasehError.

Raises:

  • (ArgumentError)


25
26
27
28
29
30
31
# File 'lib/baseh/errors.rb', line 25

def initialize(code, message, safe_for_customer: true)
  raise ArgumentError, "unknown baseH error code #{code}" unless CODES.include?(code)

  super(message)
  @code = code
  @safe_for_customer = safe_for_customer
end

Instance Attribute Details

#codeString (readonly)

Returns one of CODES.

Returns:

  • (String)

    one of CODES



20
21
22
# File 'lib/baseh/errors.rb', line 20

def code
  @code
end

#safe_for_customerBoolean (readonly)

Returns true when the message may be shown to an end user.

Returns:

  • (Boolean)

    true when the message may be shown to an end user



23
24
25
# File 'lib/baseh/errors.rb', line 23

def safe_for_customer
  @safe_for_customer
end