Exception: NRSER::Types::CheckError
- Inherits:
-
NRSER::TypeError
- Object
- TypeError
- NRSER::TypeError
- NRSER::Types::CheckError
- Defined in:
- lib/nrser/types/errors/check_error.rb
Overview
This error (or a subclass) is thrown when types fail to Type.check!.
Constant Summary
Constants included from NicerError
NicerError::DEFAULT_COLUMN_WIDTH
Instance Attribute Summary collapse
-
#type ⇒ NRSER::Types::Type
readonly
The type that was checked against.
-
#value ⇒ *
readonly
The value that failed the type check.
Instance Method Summary collapse
-
#default_message ⇒ String
Build default message when none provided.
-
#initialize(*message, value:, type:, details: nil, **kwds) ⇒ CheckError
constructor
Construct a ‘NicerError`.
Methods included from NicerError
#add_extended_message?, column_width, #context, #context_section, #details, #details_section, #extended_message, #format_message, #format_message_segment, included, #to_s
Constructor Details
#initialize(*message, value:, type:, details: nil, **kwds) ⇒ CheckError
Construct a ‘NicerError`.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/nrser/types/errors/check_error.rb', line 53 def initialize *, value:, type:, details: nil, **kwds @value = value @type = type if details.is_a?( Proc ) && details.arity != 0 orig_details = details details = -> { orig_details.call type: type, value: value } end super \ *, type: type, value: value, details: details, **kwds end |
Instance Attribute Details
#type ⇒ NRSER::Types::Type (readonly)
The type that was checked against.
27 28 29 |
# File 'lib/nrser/types/errors/check_error.rb', line 27 def type @type end |
#value ⇒ * (readonly)
The value that failed the type check.
34 35 36 |
# File 'lib/nrser/types/errors/check_error.rb', line 34 def value @value end |
Instance Method Details
#default_message ⇒ String
Build default message when none provided.
75 76 77 |
# File 'lib/nrser/types/errors/check_error.rb', line 75 def ["Value", value.inspect, "failed check for type", type.name] end |