Exception: SalesforceBulk::SalesforceError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/salesforce_bulk/salesforce_error.rb

Overview

An exception raised when any non successful request is made through the Salesforce Bulk API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ SalesforceError

Returns a new instance of SalesforceError.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/salesforce_bulk/salesforce_error.rb', line 9

def initialize(response)
  self.response = response
  
  data = XmlSimple.xml_in(response.body, 'ForceArray' => false)
  
  if data
    # seems responses for CSV requests use a different XML return format 
    # (use invalid_error.xml for reference)
    if !data['exceptionMessage'].nil?
      message = data['exceptionMessage']
    else
      # SOAP error response
      message = data['Body']['Fault']['faultstring']
    end
    
    self.error_code = response.code
  end
  
  super(message)
end

Instance Attribute Details

#error_codeObject

The status code from the server response body.



7
8
9
# File 'lib/salesforce_bulk/salesforce_error.rb', line 7

def error_code
  @error_code
end

#responseObject

The Net::HTTPResponse instance from the API call.



5
6
7
# File 'lib/salesforce_bulk/salesforce_error.rb', line 5

def response
  @response
end