Autostrada
Autostrada
Create a new codebase Get Autostrada Plus
Documentation Changelog Roadmap Give feedback
Login

DocumentationTraditional web application › Error notifications

Error notifications

If you enable the Error notifications option when generating your codebase, the application will support sending error notifications by email to a specific address.

If you're using command-line flags for configuration, you should pass the email address via the --notifications-email flag when starting the application. For example:

$ go run ./cmd/web --notifications-email="admin@example.com"

If you're using environment variables, set it in NOTIFICATIONS_EMAIL. For example:

$ export NOTIFICATIONS_EMAIL="me@example.com"

If you don't configure an email address, error notifications will not be sent (but errors will still be logged as normal).

For the emails to be sent correctly, you will also need to configure the SMTP credentials for the application to use. Please see here for information on how to do this.

The code for sending error notifications is contained in the reportServerError() method in the cmd/web/errors.go file, and the email template for the notification is located at assets/emails/error-notification.tmpl. Feel free to edit these if you want to.

Important: By default, notifications will only be sent for errors that are encountered as part of a request-response cycle (i.e. whenever a user sees a 500 Internal Server Error response). Notifications are not sent for any errors that occur when starting or shutting down the application, so it's important to still use an uptime monitoring service in production if you want to be alerted about when the application is totally unavailable.