Class: Glia::Errors::HeadersValidationError

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

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) ⇒ HeadersValidationError

Returns a new instance of HeadersValidationError.

Raises:

  • (ArgumentError)


344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/glia/errors/client_errors.rb', line 344

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

  error_details.each_key { |key| Naming.assert_header(key) }

  super(
    type: HEADERS_VALIDATION_ERROR,
    ref: create_ref(HEADERS_VALIDATION_ERROR),
    message: message || 'Headers are invalid',
    error_details: error_details
  )
end