Exception: Baseh::BasehError
- Inherits:
-
StandardError
- Object
- StandardError
- Baseh::BasehError
- 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
-
#code ⇒ String
readonly
One of CODES.
-
#safe_for_customer ⇒ Boolean
readonly
True when the message may be shown to an end user.
Instance Method Summary collapse
-
#initialize(code, message, safe_for_customer: true) ⇒ BasehError
constructor
A new instance of BasehError.
Constructor Details
#initialize(code, message, safe_for_customer: true) ⇒ BasehError
Returns a new instance of BasehError.
25 26 27 28 29 30 31 |
# File 'lib/baseh/errors.rb', line 25 def initialize(code, , safe_for_customer: true) raise ArgumentError, "unknown baseH error code #{code}" unless CODES.include?(code) super() @code = code @safe_for_customer = safe_for_customer end |
Instance Attribute Details
#code ⇒ String (readonly)
Returns one of CODES.
20 21 22 |
# File 'lib/baseh/errors.rb', line 20 def code @code end |
#safe_for_customer ⇒ Boolean (readonly)
Returns 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 |