Skip to content

WP Packages is our new WPackagist replacement that's 17x faster and updates every 5 minutes

Acorn

Roots is an independent open source org, supported only by developers like you. We’ve been improving the WordPress developer experience since 2011, and your support keeps it independent.

Error Handling in Acorn Applications

View as Markdown:

Introduction

When working in a development environment, Acorn automatically registers an exception handler configured to handle logging as well as the rendering of thrown exceptions. This can be especially useful when diagnosing errors thrown by Blade views.

Configuration

The debug option in your config/app.php is solely responsible for whether or not an exception is handled by Acorn. By default, this option is set to be enabled when WP_DEBUG && WP_DEBUG_DISPLAY are enabled in your WordPress config.

During local development, it is highly advised to ensure that WP_DEBUG is enabled to properly render exceptions thrown by Blade views and other errors further down the stack.

The exception handler

Laravel includes a built-in debug/exception page that provides a detailed and easy to read stack trace on errors thrown in your application.

Screenshot of the error page on an Acorn WordPress site

Reporting exceptions

Exception reporting can be used to log exceptions to storage or send them to an external service such as Sentry. By default, exceptions will be logged to disk located in the storage/logs folder.

Check out the documentation on logging to learn more about log implementation.

Disabling the exception handler

Acorn's acorn/throw_error_exception filter can be used to disable the exception handler:

add_filter('acorn/throw_error_exception', '__return_false');

Last updated