Sha256: bd6ea49f39ca0be3fd01ea8b2b2f76cebd8fad765afde4ac5dbb4eb9bed54647

Contents?: true

Size: 674 Bytes

Versions: 9

Compression:

Stored size: 674 Bytes

Contents

module Brochure
  class Failsafe
    def initialize(app)
      @app = app
    end

    def call(env)
      @app.call(env)
    rescue Exception => exception
      backtrace = ["#{exception.class.name}: #{exception}", *exception.backtrace].join("\n  ")
      env["rack.errors"].puts(backtrace)
      env["rack.errors"].flush

      body = <<-HTML
        <!DOCTYPE html>
        <html><head><title>Internal Server Error</title></head>
        <body><h1>500 Internal Server Error</h1></body></html>
      HTML

      [500,
       { "Content-Type"   => "text/html, charset=utf-8",
         "Content-Length" => Rack::Utils.bytesize(body).to_s },
       [body]]
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
brochure-0.5.4 lib/brochure/failsafe.rb
brochure-0.5.3 lib/brochure/failsafe.rb
brochure-0.5.2 lib/brochure/failsafe.rb
brochure-0.5.1 lib/brochure/failsafe.rb
brochure-0.5.0 lib/brochure/failsafe.rb
brochure-0.4.0 lib/brochure/failsafe.rb
brochure-0.3.1 lib/brochure/failsafe.rb
brochure-0.3.0 lib/brochure/failsafe.rb
brochure-0.2.0 lib/brochure/failsafe.rb