Class: Glia::Errors::RemainingAssociationError

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

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

Returns a new instance of RemainingAssociationError.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/glia/errors/client_errors.rb', line 133

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

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