Sha256: 8379a55a9d24e34def313589c9ae4bdc1dbb89bc5c7846d9bebf6b19b78ea817

Contents?: true

Size: 791 Bytes

Versions: 32

Compression:

Stored size: 791 Bytes

Contents

module Databasedotcom
  # An exception raised when any non successful request is made to Force.com.
  class SalesForceError < StandardError
    # the Net::HTTPResponse from the API call
    attr_accessor :response
    # the +errorCode+ from the server response body
    attr_accessor :error_code

    def initialize(response)
      self.response = response
      parsed_body = JSON.parse(response.body) rescue nil
      if parsed_body
        if parsed_body.is_a?(Array)
          message = parsed_body[0]["message"]
          self.error_code = parsed_body[0]["errorCode"]
        else
          message = parsed_body["error_description"]
          self.error_code = parsed_body["error"]
        end
      else
        message = response.body
      end
      super(message)
    end
  end
end

Version data entries

32 entries across 32 versions & 4 rubygems

Version Path
databasedotcom-1.3.2 lib/databasedotcom/sales_force_error.rb
databasedotcom_emp-1.3.1 lib/databasedotcom/sales_force_error.rb
databasedotcom_cloudfuji-1.3.1 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.3.1 lib/databasedotcom/sales_force_error.rb
databasedotcom-ejholmes-1.3.5 lib/databasedotcom/sales_force_error.rb
databasedotcom-ejholmes-1.3.4 lib/databasedotcom/sales_force_error.rb
databasedotcom-ejholmes-1.3.3 lib/databasedotcom/sales_force_error.rb
databasedotcom-ejholmes-1.3.2 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.3.0 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.2.7 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.2.6 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.2.5 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.2.4 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.2.3 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.2.2 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.2.1 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.2.0 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.1.7 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.1.6 lib/databasedotcom/sales_force_error.rb
databasedotcom-1.1.5 lib/databasedotcom/sales_force_error.rb