Class: Glia::Errors::InputValidationError

Inherits:
Error
  • Object
show all
Defined in:
lib/glia/errors/client_errors.rb

Overview

rubocop:disable Style/Documentation

Instance Attribute Summary

Attributes inherited from Error

#error_details, #message, #ref, #type

Instance Method Summary collapse

Methods inherited from Error

#to_h

Constructor Details

#initialize(error_details:, message: nil) ⇒ InputValidationError

Returns a new instance of InputValidationError.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/glia/errors/client_errors.rb', line 7

def initialize(error_details:, message: nil)
  raise ArgumentError, 'At least 1 error detail is required' if error_details.keys.count.zero?

  error_details.each_value do |value|
    raise ArgumentError, 'error_details values must be lists' unless value.is_a?(Array)
  end

  super(
    type: INPUT_VALIDATION_ERROR,
    ref: create_ref(INPUT_VALIDATION_ERROR),
    message: message || 'Input is invalid',
    error_details: error_details
  )
end