在 SilverStripe 4 中调用默认的 exceptionHandler 等价物

Calling the default exceptionHandler equivalent in SilverStripe 4

我已经在文档和 API 中搜索了 SilverStripe 4,但我在使用适当的 class 调用默认异常处理程序时遇到了问题。

在 SilverStripe 4 之前它是如何在我的 Page.php 控制器的 init()

中工作的
    parent::init();

    set_exception_handler(function($exception) {
        if( get_class($exception) == 'CustomException' ) {
            Controller::curr()->handleCustomException($exception);
        }
        return exceptionHandler($exception);
    });

我希望它如何与 SilverStripe 4 一起工作

    parent::init();

    set_exception_handler(function($exception) {
        if( get_class($exception) == 'CustomException' ) {
            Controller::curr()->handleCustomException($exception);
        }
        return <SomeMonologClass>::handleException($exception);
    });

我知道 SilverStripe 4 现在正在使用 Monolog,我遇到了 handleException 函数,我认为我需要调用它而不是 exceptionHandler($exception)

如有任何建议,我们将不胜感激。

use SilverStripe\Control\Controller;

class MyController extends Controller
{
    private static $dependencies = [
        'logger' => '%$Psr\Log\LoggerInterface',
    ];

    // This will be set automatically, as long as MyController is instantiated via Injector
    public $logger;

    protected function init()
    {
        $this->logger->debug("MyController::init() called");
        parent::init();
    }
}

如此处所述:

https://docs.silverstripe.org/en/4/developer_guides/debugging/error_handling/#accessing-the-logger-via-dependency-injection

这里还有更多信息:https://www.silverstripe.org/learn/lessons/v4/advanced-environment-configuration-1