Exception: Sequent::Core::CommandNotValid
- Inherits:
-
ArgumentError
- Object
- ArgumentError
- Sequent::Core::CommandNotValid
- Defined in:
- lib/sequent/core/command_service.rb
Overview
Raised when BaseCommand.valid? returns false
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
- #errors(prefix = nil) ⇒ Object
- #errors_with_command_prefix ⇒ Object
-
#initialize(command) ⇒ CommandNotValid
constructor
A new instance of CommandNotValid.
Constructor Details
#initialize(command) ⇒ CommandNotValid
Returns a new instance of CommandNotValid.
107 108 109 110 111 |
# File 'lib/sequent/core/command_service.rb', line 107 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
#command ⇒ Object (readonly)
Returns the value of attribute command.
105 106 107 |
# File 'lib/sequent/core/command_service.rb', line 105 def command @command end |
Instance Method Details
#errors(prefix = nil) ⇒ Object
113 114 115 116 117 |
# File 'lib/sequent/core/command_service.rb', line 113 def errors(prefix = nil) I18n.with_locale(Sequent.configuration.error_locale_resolver.call) do @command.validation_errors(prefix) end end |
#errors_with_command_prefix ⇒ Object
119 120 121 |
# File 'lib/sequent/core/command_service.rb', line 119 def errors_with_command_prefix errors(@command.class.to_s.underscore) end |