protected function isActive(): bool
    {
        if ($this->currentErrorException !== null) {
            return true;
        }

        // ugly, but there is no get_error_handler()
        $currentErrorHandler = set_error_handler(function () {});
        restore_error_handler();

        return is_array($currentErrorHandler) && $currentErrorHandler[0] === $this;
    }