Class: Utopia::Middleware::MailExceptions
- Defined in:
- lib/utopia/middleware/mail_exceptions.rb
Overview
Catches all exceptions raised from the app it wraps and sends a useful email with the exception, stacktrace, and contents of the environment.
Constant Summary collapse
- LOCAL_SMTP =
A basic local non-authenticated SMTP server.
[:smtp, { :address => "localhost", :port => 25, :enable_starttls_auto => false }]
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, config = {}) ⇒ MailExceptions
constructor
A new instance of MailExceptions.
Constructor Details
#initialize(app, config = {}) ⇒ MailExceptions
Returns a new instance of MailExceptions.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/utopia/middleware/mail_exceptions.rb', line 35 def initialize(app, config = {}) @app = app @to = config[:to] || "postmaster" @from = config.fetch(:from) {(ENV['USER'] || 'rack') + "@localhost"} @subject = config[:subject] || '%{exception} [PID %{pid} : %{cwd}]' @delivery_method = config.fetch(:delivery_method, LOCAL_SMTP) @dump_environment = config.fetch(:dump_environment, false) end |
Instance Method Details
#call(env) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/utopia/middleware/mail_exceptions.rb', line 46 def call(env) begin return @app.call(env) rescue => exception send_notification exception, env raise end end |