Exception: Crm::Errors::ItemStatePreconditionFailed

Inherits:
ClientError show all
Defined in:
lib/crm/errors.rb

Overview

ItemStatePreconditionFailed is raised if one or more preconditions for the attempted action were not satisfied. For example, a deleted item cannot be updated. It must be undeleted first.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, unmet_preconditions) ⇒ ItemStatePreconditionFailed

Returns a new instance of ItemStatePreconditionFailed.



79
80
81
82
83
84
85
# File 'lib/crm/errors.rb', line 79

def initialize(message = nil, unmet_preconditions)
  precondition_messages = unmet_preconditions.map{ |p| p['message'] }
  new_message = ([message] + precondition_messages).join(' ')
  super(new_message)

  @unmet_preconditions = unmet_preconditions
end

Instance Attribute Details

#unmet_preconditionsArray<Hash{String => String}> (readonly)

Returns the unmet preconditions. The items in the list are hashes consisting of a code (the name of the precondition), and an English translation (message).

Examples:

[
  {
    "code" => "is_internal_mailing",
    "message" => "The mailing is not an internal mailing.",
  },
]

Returns:

  • (Array<Hash{String => String}>)


77
78
79
# File 'lib/crm/errors.rb', line 77

def unmet_preconditions
  @unmet_preconditions
end