Method: NRSER::ValueError#build_message

Defined in:
lib/nrser/errors/value_error.rb

#build_messageString

Build the error message when none is provided to ‘#initialize`.

When no ‘message` (or `nil`) is provided to initialize it will call this method to get the error message just before it needs it to call up to StandardError#initialize (via `super message`).

This allows NRSER::ValueError subclasses that are able to build a useful default message or would like to augment the user-provided one to do so at the last possible moment before it’s needed, letting them work with an otherwise fully-initialized instance.

Hence a subclass several generations down from NRSER::ValueError can use values initialized in all the constructors in-between, avoiding a lot of headache.

This implementation always raises AbstractMethodError because NRSER::ValueError does not have enough information to construct a useful message.

Returns:

  • (String)

    Implementations must return the message string for StadardError#initialize.

Raises:



68
69
70
# File 'lib/nrser/errors/value_error.rb', line 68

def build_message
  raise NRSER::AbstractMethodError.new( self, __method__ )
end