Exception: ZuoraAPI::Exceptions::ZuoraAPIError

Inherits:
Error
  • Object
show all
Defined in:
lib/zuora_api/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, response = nil, errors = [], successes = [], *args) ⇒ ZuoraAPIError

Returns a new instance of ZuoraAPIError.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/zuora_api/exceptions.rb', line 44

def initialize(message = nil,response=nil, errors = [], successes = [],  *args)
  @code = response.class.to_s == "HTTParty::Response" ? response.code : nil
  
  case message
  when /Payment status should be Processed. Invalid payment is P-\d*./
    @message = "Payment status should be Processed."  
  when /Adjustment cannot be created for invoice(.*) with a zero balance./
    @message = "Adjustment cannot be created for invoice with a zero balance."
  when /The balance of all the invoice items and tax items is 0. No write-off is needed for the invoice .*./
    @message = "The balance of all the invoice items and tax items is 0. No write-off is needed for the invoice."
  else
    @message = message  
  end
  
  @response = response
  @default_message = "Error communicating with Zuora."
  @errors = errors
  @successes = successes
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



41
42
43
# File 'lib/zuora_api/exceptions.rb', line 41

def code
  @code
end

#default_message=(value) ⇒ Object (writeonly)

Sets the attribute default_message

Parameters:

  • value

    the value to set the attribute default_message to.



42
43
44
# File 'lib/zuora_api/exceptions.rb', line 42

def default_message=(value)
  @default_message = value
end

#errorsObject (readonly)

Returns the value of attribute errors.



41
42
43
# File 'lib/zuora_api/exceptions.rb', line 41

def errors
  @errors
end

#responseObject (readonly)

Returns the value of attribute response.



41
42
43
# File 'lib/zuora_api/exceptions.rb', line 41

def response
  @response
end

#successesObject (readonly)

Returns the value of attribute successes.



41
42
43
# File 'lib/zuora_api/exceptions.rb', line 41

def successes
  @successes
end

Instance Method Details

#to_sObject



64
65
66
# File 'lib/zuora_api/exceptions.rb', line 64

def to_s
  @message || @default_message
end