Exception: ZuoraAPI::Exceptions::ZuoraAPISessionError

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 = []) ⇒ ZuoraAPISessionError

Returns a new instance of ZuoraAPISessionError.



33
34
35
36
37
38
# File 'lib/zuora_api/exceptions.rb', line 33

def initialize(message = nil,response=nil, errors = [], successes = [])
  @code = response.class.to_s == "HTTParty::Response" ? response.code : nil
  @message = parse_message(message)
  @response = response
  @default_message = "Error with Zuora Session."
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



30
31
32
# File 'lib/zuora_api/exceptions.rb', line 30

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.



31
32
33
# File 'lib/zuora_api/exceptions.rb', line 31

def default_message=(value)
  @default_message = value
end

#responseObject (readonly)

Returns the value of attribute response.



30
31
32
# File 'lib/zuora_api/exceptions.rb', line 30

def response
  @response
end

Instance Method Details

#parse_message(message) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/zuora_api/exceptions.rb', line 44

def parse_message(message)
  case message
  when /^Invalid Oauth Client Id$/, /^Unable to generate token.$/
    @message = "Invalid login, please check client ID and Client Secret or URL endpoint"
  when /^Forbidden$/
    @message = "The user associated to OAuth credential set has been deactivated."
  when /^Invalid login. User name and password do not match.$/
    @message = "Invalid login, please check username and password or URL endpoint"
  else
    @message = message
  end
end

#to_sObject



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

def to_s
  @message || @default_message
end