Error Handling

Hiraeth provides robust error handling using SlashTrace. In addition to providing extensive debugging information, you can add support for additional logging and external logging services such as Sentry.

Hiraeth runs in production mode by default. This means that until you’ve set up debugging, logging, or additional services in your .env, you won’t be seeing much detail if something is going wrong. Make sure to read the below sections carefully and choose what makes the most sense for your environment.

Debugging Mode

To put the application in debugging mode, modify the .env file and make sure the following is set:

DEBUG = true

You can check if the application is in debugging mode by performing the following:

if ($app->isDebugging()) {
    ...
}

When the application is in debugging mode, you will see stacktrace and related context information presented to a web request or in the cli in accordance with SlashTrace’s standard output.

Services

SlashTrace provides the ability to create custom handlers which send error output to third-party services. Handlers are avilable for many common services, however, at present, Hiraeth only has an integration package for Sentry.

To get Sentry support enabled, install hiraeth/sentry and add your DSN in .env.

[SENTRY]

	DSN = <your sentry dsn>

Logging

You can enable logging by installing hiraeth/monolog and updating your .env to set LOGGING to the approriate log level.

LOGGING = error

Supported types map to PSR-3 LogLevel constants.

Logs of the requests level or higher will then be sent to the default file location under storage/logs.


Learn About Logging