Exception: Velocity::VelocityException

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/acceleration/velocity.rb

Overview

Generic Velocity API exception thrown when Velocity doesn’t like the arguments supplied in a call or the credentials are incorrect.

Don’t ever raise this yourself; it should be raised only by Velocity::Instance#call

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ VelocityException

Wrap this exception around the XML returned by Velocity



1265
1266
1267
1268
# File 'lib/acceleration/velocity.rb', line 1265

def initialize(node)
  @node = node
  super(api_message)
end

Class Method Details

.exception?(node) ⇒ Boolean

Determines if a response from the API is an exception response

Returns:

  • (Boolean)


1258
1259
1260
# File 'lib/acceleration/velocity.rb', line 1258

def self.exception?(node)
  node.root.name == 'exception'
end

Instance Method Details

#api_messageObject

Get the string describing the thrown exception



1273
1274
1275
# File 'lib/acceleration/velocity.rb', line 1273

def api_message
  @node.xpath('/exception//text()').to_a.join.strip
end

#to_sObject

Convert this exception to a string



1280
1281
1282
# File 'lib/acceleration/velocity.rb', line 1280

def to_s
  api_message
end