# File lib/padrino-contrib/exception_notifier.rb, line 22 def self.registered(app) app.set :exceptions_subject, "Exception" unless app.respond_to?(:exceptions_subject) app.set :exceptions_to, "errors@localhost.local" unless app.respond_to?(:exceptions_to) app.set :exceptions_from, "foo@bar.local" unless app.respond_to?(:exceptions_from) app.set :exceptions_layout, :layout unless app.respond_to?(:exceptions_layout) app.set :exceptions_views, app.views unless app.respond_to?(:exceptions_views) app.set :redmine, {} unless app.respond_to?(:redmine) app.error 500 do boom = env['sinatra.error'] body = ["#{boom.class} - #{boom.message}:", *boom.backtrace].join("\n ") body += "\n\n---Env:\n" env.each { |k,v| body += "\n#{k}: #{v}" } body += "\n\n---Params:\n" params.each { |k,v| body += "\n#{k.inspect} => #{v.inspect}" } logger.error body settings.redmine.each { |k,v| body += "\n#{k.to_s.capitalize}: #{v}" } app.email do subject "[#{app.exceptions_subject}] #{boom.class} - #{boom.message}" to app.exceptions_to from app.exceptions_from body body end response.status = 500 content_type 'text/html', :charset => "utf-8" render settings.exceptions_page, :layout => settings.exceptions_layout, :views => settings.exceptions_views end app.error 404 do response.status = 404 content_type 'text/html', :charset => "utf-8" render settings.exceptions_page, :layout => settings.exceptions_layout, :views => settings.exceptions_views end end
Generated with the Darkfish Rdoc Generator 2.