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.



128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/glia/errors/client_errors.rb', line 128

def initialize(resource:, associated_resource:, message: nil)
  default_message =
    "cannot be modified/deleted because it is associated to one or more #{
      humanize(associated_resource)
    }(s)"
  super(
    type: REMAINING_ASSOCIATION_ERROR,
    ref: "https://example.com/errors/#{REMAINING_ASSOCIATION_ERROR}.html",
    message: "#{humanize(resource)} " + (message || default_message),
    error_details: { resource: resource, associated_resource: associated_resource }
  )
end