protected function prepareErrorResponse($exception, Http\Response $response)
    {
        $pathPosition = strpos($exception->getFile(), 'Packages/');
        $filePathAndName = ($pathPosition !== false) ? substr($exception->getFile(), $pathPosition) : $exception->getFile();
        $exceptionCodeNumber = ($exception->getCode() > 0) ? '#' . $exception->getCode() . ': ' : '';
        $content = PHP_EOL . 'Uncaught Exception in Flow ' . $exceptionCodeNumber . $exception->getMessage() . PHP_EOL;
        $content .= 'thrown in file ' . $filePathAndName . PHP_EOL;
        $content .= 'in line ' . $exception->getLine() . PHP_EOL . PHP_EOL;
        $content .= Debugger::getBacktraceCode($exception->getTrace(), false, true) . PHP_EOL;

        if ($exception instanceof Exception) {
            $statusCode = $exception->getStatusCode();
        } else {
            $statusCode = 500;
        }
        $response->setStatus($statusCode);
        $response->setContent($content);
        $response->setHeader('X-Flow-ExceptionCode', $exception->getCode());
        $response->setHeader('X-Flow-ExceptionMessage', $exception->getMessage());
    }
protected function prepareErrorResponse($exception, Http\Response $response)
    {
        $pathPosition = strpos($exception->getFile(), 'Packages/');
        $filePathAndName = ($pathPosition !== false) ? substr($exception->getFile(), $pathPosition) : $exception->getFile();
        $exceptionCodeNumber = ($exception->getCode() > 0) ? '#' . $exception->getCode() . ': ' : '';
        $content = PHP_EOL . 'Uncaught Exception in Flow ' . $exceptionCodeNumber . $exception->getMessage() . PHP_EOL;
        $content .= 'thrown in file ' . $filePathAndName . PHP_EOL;
        $content .= 'in line ' . $exception->getLine() . PHP_EOL . PHP_EOL;
        $content .= Debugger::getBacktraceCode($exception->getTrace(), false, true) . PHP_EOL;

        if ($exception instanceof Exception) {
            $statusCode = $exception->getStatusCode();
        } else {
            $statusCode = 500;
        }
        $response->setStatus($statusCode);
        $response->setContent($content);
        $response->setHeader('X-Flow-ExceptionCode', $exception->getCode());
        $response->setHeader('X-Flow-ExceptionMessage', $exception->getMessage());
    }
protected function prepareErrorResponse ( $ exception , Http \ Response $ response ) { $ pathPosition = strpos ( $ exception -> getFile ( ) , 'Packages/' ) ; $ filePathAndName = ( $ pathPosition !== false ) ? substr ( $ exception -> getFile ( ) , $ pathPosition ) : $ exception -> getFile ( ) ; $ exceptionCodeNumber = ( $ exception -> getCode ( ) > 0 ) ? '#' . $ exception -> getCode ( ) . ': ' : '' ; $ content = PHP_EOL . 'Uncaught Exception in Flow ' . $ exceptionCodeNumber . $ exception -> getMessage ( ) . PHP_EOL ; $ content .= 'thrown in file ' . $ filePathAndName . PHP_EOL ; $ content .= 'in line ' . $ exception -> getLine ( ) . PHP_EOL . PHP_EOL ; $ content .= Debugger :: getBacktraceCode ( $ exception -> getTrace ( ) , false , true ) . PHP_EOL ; if ( $ exception instanceof Exception ) { $ statusCode = $ exception -> getStatusCode ( ) ; } else { $ statusCode = 500 ; } $ response -> setStatus ( $ statusCode ) ; $ response -> setContent ( $ content ) ; $ response -> setHeader ( 'X-Flow-ExceptionCode' , $ exception -> getCode ( ) ) ; $ response -> setHeader ( 'X-Flow-ExceptionMessage' , $ exception -> getMessage ( ) ) ; }
Prepare a response in case an error occurred.

@param object $exception \Exception or \Throwable
@param Http\Response $response
@return void
Prepare a response in case an error occurred .