Exception: RepsClient::ServiceError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/reps_client/errors.rb

Overview

Represents a server-side error returned by the REPS web service.

Direct Known Subclasses

InvalidEnterpriseKeyError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, code = nil) ⇒ ServiceError

Creates a new error object.

Parameters:

  • message (String) (defaults to: nil)

    the error message. If no message is supplied, the object’s class name will be used as the message.

  • code (String) (defaults to: nil)

    the error code



11
12
13
14
# File 'lib/reps_client/errors.rb', line 11

def initialize(message=nil, code=nil)
  super(message)
  @code = code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/reps_client/errors.rb', line 4

def code
  @code
end

Class Method Details

.translate_fault(soap_error) ⇒ RepsClient::ServiceError

Translates a soap fault into the appropriate RepsClient error.

Parameters:

  • soap_error (Savon::SOAP::Fault)

    the error object raised by the soap client

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/reps_client/errors.rb', line 20

def self.translate_fault(soap_error)
  fault = soap_error.to_hash[:fault]

  # set up defaults
  error_class = RepsClient::ServiceError

  if fault[:faultcode] == 'InvalidEnterpriseKey'
    error_class = RepsClient::InvalidEnterpriseKeyError
  end

  error_class.new(fault[:faultstring], fault[:faultcode])
end