public function handleError()
    {
        if (!$this->shutdownHandlerActive) {
            return;
        }

        $error = error_get_last();

        if ($error['type'] === E_ERROR) {
            $message = sprintf('Error: "%s" in %s on %s', $error['message'], $error['file'], $error['line']);
            $this->task->markError();
            $this->task->addOutput($message);
            $this->logger->error($message);
        }

        // Ensure to release the lock.
        $this->releaseLock();
    }