Class: Cuprum::Rails::Errors::ResourceError

Inherits:
Error
  • Object
show all
Defined in:
lib/cuprum/rails/errors/resource_error.rb

Overview

Error class when a resource is not correctly configured for an action.

Constant Summary collapse

TYPE =

Short string used to identify the type of error.

'cuprum.rails.errors.resource_error'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource:, message: nil) ⇒ ResourceError

Returns a new instance of ResourceError.

Parameters:

  • resource (Cuprum::Rails::Resource)

    the errored resource.

  • message (String) (defaults to: nil)

    the message to display, if any.



15
16
17
18
19
# File 'lib/cuprum/rails/errors/resource_error.rb', line 15

def initialize(resource:, message: nil)
  @resource = resource

  super(message: generate_message(message), resource: resource)
end

Instance Attribute Details

#resourceCuprum::Rails::Resource (readonly)

Returns the errored resource.

Returns:



22
23
24
# File 'lib/cuprum/rails/errors/resource_error.rb', line 22

def resource
  @resource
end