Exception: RubyReactor::Error::InputValidationError

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_reactor/error/input_validation_error.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#context, #original_error, #step

Instance Method Summary collapse

Constructor Details

#initialize(field_errors) ⇒ InputValidationError

Returns a new instance of InputValidationError.



8
9
10
11
12
# File 'lib/ruby_reactor/error/input_validation_error.rb', line 8

def initialize(field_errors)
  @field_errors = field_errors
  @message = build_message
  super(@message)
end

Instance Attribute Details

#field_errorsObject (readonly)

Returns the value of attribute field_errors.



6
7
8
# File 'lib/ruby_reactor/error/input_validation_error.rb', line 6

def field_errors
  @field_errors
end

Instance Method Details

#build_messageObject



14
15
16
17
18
19
20
21
22
# File 'lib/ruby_reactor/error/input_validation_error.rb', line 14

def build_message
  return "Input validation failed" if field_errors.empty?

  error_messages = field_errors.map do |field, errors|
    "#{field} #{errors}"
  end

  "Input validation failed: #{error_messages.join(", ")}"
end

#to_sObject



24
25
26
# File 'lib/ruby_reactor/error/input_validation_error.rb', line 24

def to_s
  @message || build_message
end