# Exception handling

XR Debug provides a throwable handler can hook or replace your existing exception handler logic.

ThrowableHandler

Check our ThrowableHandler (opens new window) package for more into exception & error handling for PHP software. The chevere/throwable-handler package is included with XR Debug.

# Register XR Debug handler

Use Chevere\Xr\registerThrowableHandler to enable XR Debug throwable handling.


use Chevere\Xr\registerThrowableHandler;

// True append XR Debug to your existing handler
// False use only XR Debug handler
registerThrowableHandler(true);

# Triggered handler

Use Chevere\Xr\throwableHandler in any existing exception handler logic:

use Chevere\Xr\throwableHandler;

set_exception_handler(
    function(Throwable $throwable) {
        // ...
        try {
            throwableHandler($throwable);
        } catch(Throwable) {
            // Don't panic
        }
    }
);