<?php function previous_handler(Throwable $e) { printf("This is the PREVIOUS handler for %s\n", $e->getMessage()); } //------------ class Configurator { public static function setupPhpErrorListener(): void { $controller = new PhpErrorController(); $controller->usePreviousExceptionHandler(set_exception_handler([$controller, 'onException'])); } } class PhpErrorController { private $previous = null; public function usePreviousExceptionHandler(?callable $previous): void { $this->previous = $previous; } public function onException(Throwable $throwable): void { printf("This is the WONOLOG handler for %s\n", $throwable->getMessage()); if ($this->previous === null) { throw $throwable; } ($this->previous)($throwable); } } //------------ set_exception_handler('previous_handler'); Configurator::setupPhpErrorListener(); throw new Exception('Test exception');
You have javascript disabled. You will not be able to edit any code.