Sha256: be6888dab03d172614fe2777fac66c3d0dfc78c208113e4fedbb6417ee215185

Contents?: true

Size: 822 Bytes

Versions: 48

Compression:

Stored size: 822 Bytes

Contents

module Pact
  module Consumer
    class MockService
      class ErrorHandler

        def initialize app, logger
          @app = app
          @logger = logger
        end

        def call env
          begin
            @app.call(env)
          rescue Pact::Error => e
            @logger.error e.message
            [500, {'Content-Type' => 'application/json'}, [{message: e.message}.to_json]]
          rescue StandardError => e
            message = "Error ocurred in mock service: #{e.class} - #{e.message}"
            @logger.error message
            @logger.error e.backtrace.join("\n")
            [500, {'Content-Type' => 'application/json'}, [{message: message, backtrace: e.backtrace}.to_json]]
          end
        end

        def shutdown
          @app.shutdown
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
pact-mock_service-3.12.3 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.12.2 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.12.1 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.12.0 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.11.2 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.11.1 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.11.0 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.10.0 lib/pact/consumer/mock_service/error_handler.rb
hs-pact-mock_service-3.9.2 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.9.1 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.9.0 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.8.0 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.7.0 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.6.2 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.6.1 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.6.0 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.5.0 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.4.0 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.3.1 lib/pact/consumer/mock_service/error_handler.rb
pact-mock_service-3.3.0 lib/pact/consumer/mock_service/error_handler.rb