Sha256: 3308aac792e4b7eafb0849edc80c825703abd27d64f80983f01211630fdc53e6

Contents?: true

Size: 759 Bytes

Versions: 19

Compression:

Stored size: 759 Bytes

Contents

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

      private

      attr_reader :exception, :original_message, :handler_klass

      public

      def initialize(exception, handler_klass = ErrorHandler)
        @exception        = exception.class
        @original_message = exception.message
        @handler_klass    = handler_klass
      end

      def run
        handler = handler_klass.find exception
        handler.original_message = original_message

        handler.execute(parsed_message)
      end

      private

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

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

Version data entries

19 entries across 18 versions & 1 rubygems

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