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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, unmet_preconditions) ⇒ ItemStatePreconditionFailed

Returns a new instance of ItemStatePreconditionFailed.



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

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}>)


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

def unmet_preconditions
  @unmet_preconditions
end