class Triton::RemoteException
In tests, you can also `raise Triton::RemoteExceptions::WidgetFailure, 'the-message' and also `raise Triton::RemoteException
, { “code” => 'WidgetFailure', 'message' => 'the-message' } with the same behaviour
Attributes
body[R]
code[R]
errors[R]
Public Class Methods
exception(payload)
click to toggle source
# File lib/triton/remote_exception.rb, line 30 def self.exception(payload) if payload.is_a?(Hash) && payload.keys.include?('code') const = Triton::RemoteExceptions.const_get(payload['code'].intern) const.new(payload) else self.new(payload) end end
new(hash_or_string)
click to toggle source
Calls superclass method
# File lib/triton/remote_exception.rb, line 41 def initialize(hash_or_string) if hash_or_string.is_a?(Hash) @errors = hash_or_string['errors'] @code = hash_or_string['code'] @body = hash_or_string super(hash_or_string.fetch('message') { body.to_s }) else super(hash_or_string) end end