class ProxyTester::Actions::HandleError

Attributes

backtrace[R]
exception[R]
handler_klass[R]
original_message[R]

Public Class Methods

new(exception, handler_klass = ErrorHandler) click to toggle source
# File lib/proxy_tester/actions/handle_error.rb, line 12
def initialize(exception, handler_klass = ErrorHandler)
  @exception        = exception.class
  @original_message = exception.message
  @backtrace        = exception.backtrace
  @handler_klass    = handler_klass
end

Public Instance Methods

run() click to toggle source
# File lib/proxy_tester/actions/handle_error.rb, line 19
def run
  handler                  = handler_klass.find exception
  handler.original_message = original_message
  handler.backtrace        = backtrace

  handler.execute(parsed_message)
end

Private Instance Methods

parsed_message() click to toggle source
# File lib/proxy_tester/actions/handle_error.rb, line 29
def parsed_message
  result = JSON.parse(original_message)
  return {} unless result.kind_of? Hash

  result
rescue JSON::ParserError
  {}
end