module Wamp::Client::Response
Constants
- DEFAULT_ERROR
Public Class Methods
from_hash(hash)
click to toggle source
This method will instantiate either a CallResult
or CallError
based on the payload
@param hash [Hash] - The hash @return [CallResult, CallError] - The result
# File lib/wamp/client/response.rb, line 40 def self.from_hash(hash) if hash[:error] != nil CallError.from_hash(hash) else CallResult.from_hash(hash) end end
invoke_handler(error: false, &callback)
click to toggle source
This method wraps the handling of the result from a procedure. or interrupt. It is intended to standardize the processing
@param [Bool] - “true” is we want an error out of this @return [CallResult, CallError
, CallDefer] - A response object
# File lib/wamp/client/response.rb, line 13 def self.invoke_handler(error: false, &callback) logger = Wamp::Client.logger # Invoke the request begin result = callback.call rescue CallError => e result = e rescue StandardError => e logger.error("Wamp::Client::Response - #{e.message}") e.backtrace.each { |line| logger.error(" #{line}") } result = CallError.new(DEFAULT_ERROR, [e.message], { backtrace: e.backtrace }) end # Ensure an expected class is returned if error CallError.ensure(result) else CallResult.ensure(result, allow_error: true, allow_defer: true) end end