2014-06-14 22:05:32 +02:00
|
|
|
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
|
2012-08-14 00:39:06 +02:00
|
|
|
|
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
|
2012-10-14 07:37:24 +02:00
|
|
|
|
2014-06-07 00:32:00 +02:00
|
|
|
def after_configuration
|
2014-06-14 22:05:32 +02:00
|
|
|
app.use ::Rack::ShowExceptions if app.config[:show_exceptions]
|
2012-05-07 23:41:39 +02:00
|
|
|
end
|
2011-12-09 20:11:17 +01:00
|
|
|
end
|
2012-08-14 00:39:06 +02:00
|
|
|
end
|