protected function prepareException($exception)
    {
        if (! $exception instanceof Exception && ! $exception instanceof Error) {
            $exception = new FatalThrowableError($exception);
        } elseif ($exception instanceof Error) {
            $trace = $exception->getTrace();

            $exception = new FatalErrorException(
                $exception->getMessage(),
                $exception->getCode(),
                \E_ERROR,
                $exception->getFile(),
                $exception->getLine(),
                \count($trace),
                \count($trace) !== 0,
                $trace
            );
        }

        return $exception;
    }