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.



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

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

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



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

def command
  @command
end

Instance Method Details

#errors(prefix = nil) ⇒ Object



124
125
126
127
128
# File 'lib/sequent/core/command_service.rb', line 124

def errors(prefix = nil)
  I18n.with_locale(Sequent.configuration.error_locale_resolver.call) do
    @command.validation_errors(prefix)
  end
end

#errors_with_command_prefixObject



130
131
132
# File 'lib/sequent/core/command_service.rb', line 130

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