Exception: Sequent::Core::CommandNotValid

Inherits:
ArgumentError
  • Object
show all
Defined in:
lib/sequent/core/command_service.rb

Overview

Raised when BaseCommand.valid? returns false

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ CommandNotValid

Returns a new instance of CommandNotValid.



109
110
111
112
113
# File 'lib/sequent/core/command_service.rb', line 109

def initialize(command)
  @command = command
  msg = @command.respond_to?(:aggregate_id) ? " #{@command.aggregate_id}" : ""
  super "Invalid command #{@command.class.to_s}#{msg}, errors: #{@command.validation_errors}"
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



107
108
109
# File 'lib/sequent/core/command_service.rb', line 107

def command
  @command
end

Instance Method Details

#errors(prefix = nil) ⇒ Object



115
116
117
# File 'lib/sequent/core/command_service.rb', line 115

def errors(prefix = nil)
  @command.validation_errors(prefix)
end

#errors_with_command_prefixObject



119
120
121
# File 'lib/sequent/core/command_service.rb', line 119

def errors_with_command_prefix
  errors(@command.class.to_s.underscore)
end