enhanceError example

$message = 'Uncaught '.$message;
            } else {
                $message = 'Uncaught Exception: '.$message;
            }

            try {
                $this->loggers[$type][0]->log($this->loggers[$type][1]$message['exception' => $exception]);
            } catch (\Throwable $handlerException) {
            }
        }

        $exception = $this->enhanceError($exception);

        $exceptionHandler = $this->exceptionHandler;
        $this->exceptionHandler = [$this, 'renderException'];

        if (null === $exceptionHandler || $exceptionHandler === $this->exceptionHandler) {
            $this->exceptionHandler = null;
        }

        try {
            if (null !== $exceptionHandler) {
                $exceptionHandler($exception);

                
public function onKernelException(ExceptionEvent $event)
    {
        if (null === $this->controller) {
            return;
        }

        $throwable = $event->getThrowable();

        if ($exceptionHandler = set_exception_handler(var_dump(...))) {
            restore_exception_handler();
            if (\is_array($exceptionHandler) && $exceptionHandler[0] instanceof ErrorHandler) {
                $throwable = $exceptionHandler[0]->enhanceError($event->getThrowable());
            }
        }

        $request = $this->duplicateRequest($throwable$event->getRequest());

        try {
            $response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false);
        } catch (\Exception $e) {
            $f = FlattenException::createFromThrowable($e);

            $this->logException($esprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', $f->getClass()$f->getMessage()basename($e->getFile())$e->getLine()));

            
Home | Imprint | This part of the site doesn't use cookies.