class Mailer < Protocol::HTTP::Middleware
- Inherits from
Protocol::HTTP::Middleware
A middleware which catches application exceptions and sends an email containing the exception, backtrace, request, and application state.
Definitions
LOCAL_SMTP = [...]
A basic local non-authenticated SMTP server.
Implementation
LOCAL_SMTP = [:smtp, {
:address => "localhost",
:port => 25,
:enable_starttls_auto => false
}]
def initialize(app, to: "postmaster", from: DEFAULT_FROM, subject: DEFAULT_SUBJECT, delivery_method: LOCAL_SMTP, dump_environment: false)
Implementation
def initialize(app, to: "postmaster", from: DEFAULT_FROM, subject: DEFAULT_SUBJECT, delivery_method: LOCAL_SMTP, dump_environment: false)
super(app)
@to = to
@from = from
@subject = subject
@delivery_method = delivery_method
@dump_environment = dump_environment
end
def freeze
Freeze this object and its internal state.
Signature
-
returns
self This object.
Implementation
def freeze
return self if frozen?
@to.freeze
@from.freeze
@subject.freeze
@delivery_method.freeze
@dump_environment.freeze
super
end
def call(request)
Report application exceptions by email before returning an error response.
Signature
-
parameter
requestUtopia::Request The request.
-
returns
Protocol::HTTP::Response The application response or a generated error response.
Implementation
def call(request)
begin
return @delegate.call(request)
rescue => exception
request.exception = exception
send_notification exception, request
raise
end
end