Module: Wamp::Client::Response
- Defined in:
- lib/wamp/client/response.rb
Defined Under Namespace
Classes: CallDefer, CallError, CallResult, ProgressiveCallDefer
Constant Summary collapse
- DEFAULT_ERROR =
"wamp.error.runtime"
Class Method Summary collapse
-
.from_hash(hash) ⇒ CallResult, CallError
This method will instantiate either a CallResult or CallError based on the payload.
-
.invoke_handler(error: false, &callback) ⇒ CallResult, ...
This method wraps the handling of the result from a procedure.
Class Method Details
.from_hash(hash) ⇒ CallResult, CallError
This method will instantiate either a CallResult or CallError based on the payload
40 41 42 43 44 45 46 |
# 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) ⇒ CallResult, ...
This method wraps the handling of the result from a procedure. or interrupt. It is intended to standardize the processing
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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.], { 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 |