Sha256: 68d9aec4c71f0103b5cb80f783a5611adc99aab643a0a0b0bad930367a17e286

Contents?: true

Size: 456 Bytes

Versions: 2

Compression:

Stored size: 456 Bytes

Contents

require 'multi_json'

module DocverterServer
  class ErrorHandler
    def initialize(app)
      @app = app
    end

    def call(env)
      begin
        @app.call env
      rescue => ex
        env['rack.errors'].puts ex
        env['rack.errors'].puts ex.backtrace.join("\n")
        env['rack.errors'].flush

        hash = { :error => ex.to_s }

        [500, {'Content-Type' => 'application/json'}, [MultiJson.dump(hash)]]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docverter-server-1.0.3-java lib/docverter-server/error_handler.rb
docverter-server-1.0.2-java lib/docverter-server/error_handler.rb