Skip to content

Commit

Permalink
Merge pull request #26 from jthibeaux/master
Browse files Browse the repository at this point in the history
raise exception when salesforce returns an exception for job
  • Loading branch information
Yatish Mehta committed Aug 26, 2014
2 parents eb6c8d4 + fbcd7a6 commit e307278
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/salesforce_bulk_api/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module SalesforceBulkApi

class Job

class SalesforceException < StandardError; end

def initialize(operation, sobject, records, external_field, connection)
@operation = operation
@sobject = sobject
Expand Down Expand Up @@ -32,6 +34,9 @@ def create_job(batch_size, send_nulls, no_null_list)
response = @connection.post_xml(nil, path, xml, headers)
response_parsed = XmlSimple.xml_in(response)

# response may contain an exception, so raise it
raise SalesforceException.new("#{response_parsed['exceptionMessage'][0]} (#{response_parsed['exceptionCode'][0]})") if response_parsed['exceptionCode']

@job_id = response_parsed['id'][0]

end
Expand Down

0 comments on commit e307278

Please sign in to comment.