Class: Utopia::Exceptions::Mailer
- Inherits:
-
Object
- Object
- Utopia::Exceptions::Mailer
- Defined in:
- lib/utopia/exceptions/mailer.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 = {}) ⇒ Mailer
constructor
A new instance of Mailer.
Constructor Details
#initialize(app, config = {}) ⇒ Mailer
Returns a new instance of Mailer.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/utopia/exceptions/mailer.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/exceptions/mailer.rb', line 46 def call(env) begin return @app.call(env) rescue => exception send_notification exception, env raise end end |