Class: Glia::Errors::RemainingAssociationError

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:, associated_resource:, message: nil) ⇒ RemainingAssociationError

Returns a new instance of RemainingAssociationError.



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/glia/errors/client_errors.rb', line 167

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

  default_message =
    "cannot be modified/deleted because it is associated to one or more #{
      Naming.humanize(associated_resource)
    }(s)"
  super(
    type: REMAINING_ASSOCIATION_ERROR,
    ref: create_ref(REMAINING_ASSOCIATION_ERROR),
    message: message || "#{Naming.humanize(resource)} #{default_message}",
    error_details: { resource: resource, associated_resource: associated_resource }
  )
end