Exception: DataObjects::Salesforce::SOAPError

Inherits:
Error
  • Object
show all
Defined in:
lib/do_salesforce/error.rb,
lib/do_salesforce/errors.rb

Direct Known Subclasses

CreateError, DeleteError, QueryError, UpdateError

Instance Method Summary collapse

Constructor Details

#initialize(message, result) ⇒ SOAPError

Returns a new instance of SOAPError.



14
15
16
17
# File 'lib/do_salesforce/error.rb', line 14

def initialize(message, result)
  @result = result
  super("#{message}: #{result_message}")
end

Instance Method Details

#failed_recordsObject



23
24
25
# File 'lib/do_salesforce/error.rb', line 23

def failed_records
  @result.reject {|r| r.success}
end

#message_for_record(record) ⇒ Object



37
38
39
# File 'lib/do_salesforce/error.rb', line 37

def message_for_record(record)
  record.errors.map {|e| "#{e.statusCode}: #{e.message}"}.join(", ")
end

#recordsObject



19
20
21
# File 'lib/do_salesforce/error.rb', line 19

def records
  @result.to_a
end

#result_messageObject



31
32
33
34
35
# File 'lib/do_salesforce/error.rb', line 31

def result_message
  failed_records.map do |r|
    message_for_record(r)
  end.join("; ")
end

#server_unavailable?Boolean

Returns:

  • (Boolean)


41
42
43
44
45
# File 'lib/do_salesforce/error.rb', line 41

def server_unavailable?
  failed_records.any? do |record|
    record.errors.any? {|e| e.statusCode == "SERVER_UNAVAILABLE"}
  end
end

#successful_recordsObject



27
28
29
# File 'lib/do_salesforce/error.rb', line 27

def successful_records
  @result.select {|r| r.success}
end