Class: Glia::Errors::ChangingFieldNotAllowedError

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

Returns a new instance of ChangingFieldNotAllowedError.



252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/glia/errors/client_errors.rb', line 252

def initialize(resource:, field:, message: nil)
  Naming.assert_snake_case(resource)
  Naming.assert_snake_case(field)

  default_message =
    "Once value of `#{field}` is set for the #{Naming.humanize(resource, lowercase: true)}, it cannot be changed"

  super(
    type: CHANGING_FIELD_NOT_ALLOWED_ERROR,
    ref: create_ref(CHANGING_FIELD_NOT_ALLOWED_ERROR),
    message: message || default_message,
    error_details: { resource: resource, field: field }
  )
end