Exception: NRSER::Types::FromStringError
- Includes:
- NicerError
- Defined in:
- lib/nrser/types/errors/from_string_error.rb
Overview
Raised when a Type fails to load a value from a String (via it’s ‘#from_s` method).
This is a NicerError.
Constant Summary
Constants included from NicerError
NicerError::DEFAULT_COLUMN_WIDTH
Instance Attribute Summary collapse
-
#string ⇒ String
readonly
The string we were trying to load from.
-
#type ⇒ NRSER::Types::Type
readonly
The type that was checked against.
Instance Method Summary collapse
-
#default_message ⇒ String
Main message to use when none provided to #initialize.
-
#initialize(*message, string:, type:, **kwds) ⇒ FromStringError
constructor
Construct a ‘FromStringError`.
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, string:, type:, **kwds) ⇒ FromStringError
Construct a ‘FromStringError`.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/nrser/types/errors/from_string_error.rb', line 62 def initialize *, string:, type:, **kwds @string = string @type = type super \ *, type: type, string: string, **kwds end |
Instance Attribute Details
#string ⇒ String (readonly)
The string we were trying to load from.
43 44 45 |
# File 'lib/nrser/types/errors/from_string_error.rb', line 43 def string @string end |
#type ⇒ NRSER::Types::Type (readonly)
The type that was checked against.
36 37 38 |
# File 'lib/nrser/types/errors/from_string_error.rb', line 36 def type @type end |
Instance Method Details
#default_message ⇒ String
Main message to use when none provided to #initialize.
78 79 80 |
# File 'lib/nrser/types/errors/from_string_error.rb', line 78 def ["Failed to load type", type.name, "from string", string.inspect] end |