class NRSER::Types::FromStringError
Raised when a {NRSER::Types::Type} fails to load a value from a {String} (via it's `#from_s` method).
This is a {NRSER::NicerError}.
Attributes
string[R]
The string we were trying to load from.
@return [String]
type[R]
The type that was checked against.
@return [NRSER::Types::Type]
Public Class Methods
new(*message, string:, type:, **kwds)
click to toggle source
Construct a `FromStringError`.
@param *message (see NRSER::NicerError#initialize)
@param [String] string
The string the type was trying to load a value from.
@param [NRSER::Types::Type] type
The type that was trying to load.
@param [Hash] kwds
See {NRSER::NicerError#initialize}
Calls superclass method
NRSER::NicerError::new
# File lib/nrser/types/errors/from_string_error.rb, line 62 def initialize *message, string:, type:, **kwds @string = string @type = type super \ *message, type: type, string: string, **kwds end
Public Instance Methods
default_message()
click to toggle source
Main message to use when none provided to {#initialize}.
@return [String]
# File lib/nrser/types/errors/from_string_error.rb, line 78 def default_message ["Failed to load type", type.name, "from string", string.inspect] end