protected function convert(\Exception $exception)
    {
        $statusCode = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR;
        $file = Path::makeRelative($exception->getFile(), $this->pathResolver->resolve('root'));

        $response = new JsonResponse([
            'success'   => false,
            'code'      => $statusCode,
            'error'     => [
                'type'    => $this->getErrorType($exception),
                'file'    => $file,
                'line'    => $exception->getLine(),
                'message' => $exception->getMessage(),
            ],
        ]);
        $response->setStatusCode($statusCode);

        return $response;
    }
protected function convert(\Exception $exception)
    {
        $statusCode = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR;
        $file = Path::makeRelative($exception->getFile(), $this->pathResolver->resolve('root'));

        $response = new JsonResponse([
            'success'   => false,
            'code'      => $statusCode,
            'error'     => [
                'type'    => $this->getErrorType($exception),
                'file'    => $file,
                'line'    => $exception->getLine(),
                'message' => $exception->getMessage(),
            ],
        ]);
        $response->setStatusCode($statusCode);

        return $response;
    }
protected function convert ( \ Exception $ exception ) { $ statusCode = $ exception instanceof HttpExceptionInterface ? $ exception -> getStatusCode ( ) : Response :: HTTP_INTERNAL_SERVER_ERROR ; $ file = Path :: makeRelative ( $ exception -> getFile ( ) , $ this -> pathResolver -> resolve ( 'root' ) ) ; $ response = new JsonResponse ( [ 'success' => false , 'code' => $ statusCode , 'error' => [ 'type' => $ this -> getErrorType ( $ exception ) , 'file' => $ file , 'line' => $ exception -> getLine ( ) , 'message' => $ exception -> getMessage ( ) , ] , ] ) ; $ response -> setStatusCode ( $ statusCode ) ; return $ response ; }
Convert the exception to a response.

@param \Exception $exception

@return JsonResponse
Convert the exception to a response .