middleman/middleman-core/lib/middleman-core/core_extensions/show_exceptions.rb

19 lines
531 B
Ruby
Raw Normal View History

require 'rack/showexceptions'
2012-01-14 21:18:39 +01:00
# Support rack/showexceptions during development
2014-06-07 00:32:00 +02:00
module Middleman::CoreExtensions
class ShowExceptions < ::Middleman::Extension
def initialize(app, options_hash={}, &block)
super
2014-07-16 03:01:45 +02:00
return if app.config.defines_setting? :show_exceptions
2014-07-08 04:43:22 +02:00
app.config.define_setting :show_exceptions, !!ENV['TEST'], 'Whether to catch and display exceptions'
2014-06-07 00:32:00 +02:00
end
2014-06-07 00:32:00 +02:00
def after_configuration
2014-06-29 00:07:43 +02:00
app.use ::Rack::ShowExceptions if !app.build? && app.config[:show_exceptions]
end
end
end