Skip to content

About Errors

Daniel Pimley edited this page Oct 17, 2020 · 21 revisions

Chyrp Lite offers a few ways to handle and report errors. The level of error reporting and the verbosity of output depends on whether debug mode is enabled.

Triggering errors

In production mode, errors of level E_NOTICE and E_USER_NOTICE will be ignored, meaning that you can use the following code to trigger errors that are reported only in debug mode:

trigger_error("Foobar!", E_USER_NOTICE);

Reporting Errors

error()

The error() function is the backbone of error handling in Chyrp Lite. It will be called automatically if an error or exception is encountered, but it can also be called directly. Be aware that this will report the error to the visitor on a pretty error page and then end execution immediately, so it’s best avoided for recoverable errors.

Flash::warning

For recoverable errors you can use the Flash class to display a warning to the user. Chyrp Lite generally tries to use flashes to report errors encountered on the visitor-facing blog pages. You’ll see Flash being used a lot in MainController, for example.

Backtraces

In debug mode, a backtrace will be captured and enumerated on the pretty error page displayed by error().

Logging

In debug mode, failure states will be logged to the file error_log.txt in the install directory.

Clone this wiki locally