Sha256: 59c28305985238ecfd3ec846a160f587f21d97dfc1f38ae339c6d2039eae2589

Contents?: true

Size: 775 Bytes

Versions: 15

Compression:

Stored size: 775 Bytes

Contents

# encoding: utf-8
module ProxyTester
  module Actions
    class HandleError

      private

      attr_reader :handler_klass, :exception

      public

      def initialize(exception, handler_klass = ErrorHandler)
        @exception     = exception
        @handler_klass = handler_klass
      end

      def run
        handler = handler_klass.find exception

        if exception.respond_to? :cause
          handler.cause = exception.cause
        else
          handler.cause = exception
        end

        handler.execute(parsed_message)
      end

      private

      def parsed_message
        result = JSON.parse(exception.message)
        return {} unless result.kind_of? Hash

        result
      rescue JSON::ParserError
        {}
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
proxy_tester-0.1.6 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.1.5 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.1.4 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.1.3 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.1.2 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.1.1 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.1.0 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.0.9 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.0.8 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.0.7 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.0.6 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.0.5 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.0.4 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.0.3 lib/proxy_tester/actions/handle_error.rb
proxy_tester-0.0.2 lib/proxy_tester/actions/handle_error.rb