Class: Glia::Errors::InvalidFormatError

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

Defined Under Namespace

Classes: Formats

Constant Summary

Constants inherited from Error

Error::SNAKE_CASE_REGEX

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(field:, format: nil, message: nil) ⇒ InvalidFormatError

Returns a new instance of InvalidFormatError.



55
56
57
58
59
60
61
62
63
# File 'lib/glia/errors/client_errors.rb', line 55

def initialize(field:, format: nil, message: nil)
  default_message =
    format ? "has invalid format, required format is #{format}" : 'has invalid format'
  super(
    type: INVALID_FORMAT_ERROR,
    ref: create_ref(INVALID_FORMAT_ERROR),
    message: message || "#{humanize(field)} #{default_message}"
  )
end