Exception: Rospatent::Errors::ValidationError

Inherits:
InvalidRequestError show all
Defined in:
lib/rospatent/errors.rb

Overview

Raised for validation errors with detailed field information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, errors = {}) ⇒ ValidationError

Initialize a new validation error

Parameters:

  • message (String)

    Error message

  • errors (Hash) (defaults to: {})

    Field-specific validation errors



105
106
107
108
# File 'lib/rospatent/errors.rb', line 105

def initialize(message, errors = {})
  @errors = errors
  super(message)
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



100
101
102
# File 'lib/rospatent/errors.rb', line 100

def errors
  @errors
end

Instance Method Details

#to_sObject



110
111
112
113
114
115
116
117
# File 'lib/rospatent/errors.rb', line 110

def to_s
  msg = super
  if @errors&.any?
    field_errors = @errors.map { |field, error| "#{field}: #{error}" }
    msg += " (#{field_errors.join(', ')})"
  end
  msg
end