Process the given $exception with the default response

@param \Orpheus\Exception\UserException $exception
@param array $values
@return \Orpheus\InputController\OutputResponse
332624
public function processUserException(UserException $exception, $values=array()) {
		// This exception is a user one, we use an app page
		$response = $this->defaultResponse;
		return $response::generateFromUserException($exception, $values);
	}
738101
private function createResponseFromOAuthException(OAuth2Exception $exception): ResponseInterface
    {
        $payload = [
            'error' => $exception->getCode(),
            'error_description' => $exception->getMessage(),
        ];

        return new Response\JsonResponse($payload, 400);
    }
179186
public function handleException($exception)
    {
        if ($exception instanceof ExitException) {
            return;
        }

        $this->exception = $exception;

        // disable error capturing to avoid recursive errors while handling exceptions
        $this->unregister();

        // set preventive HTTP status code to 500 in case error handling somehow fails and headers are sent
        // HTTP exceptions will override this value in renderException()
        if (PHP_SAPI !== 'cli') {
            http_response_code(500);
        }

        try {
            $this->logException($exception);
            if ($this->discardExistingOutput) {
                $this->clearOutput();
            }
            $this->renderException($exception);
            if (!YII_ENV_TEST) {
                \Yii::getLogger()->flush(true);
                if (defined('HHVM_VERSION')) {
                    flush();
                }
                exit(1);
            }
        } catch (\Exception $e) {
            // an other exception could be thrown while displaying the exception
            $msg = "An Error occurred while handling another error:\n";
            $msg .= (string) $e;
            $msg .= "\nPrevious exception:\n";
            $msg .= (string) $exception;
            if (YII_DEBUG) {
                if (PHP_SAPI === 'cli') {
                    echo $msg . "\n";
                } else {
                    echo '<pre>' . htmlspecialchars($msg, ENT_QUOTES, Yii::$app->charset) . '</pre>';
                }
            } else {
                echo 'An internal server error occurred.';
            }
            $msg .= "\n\$_SERVER = " . VarDumper::export($_SERVER);
            error_log($msg);
            if (defined('HHVM_VERSION')) {
                flush();
            }
            exit(1);
        }

        $this->exception = null;
    }
793826
public function exception($exception, $user_message=null) {
	if ($exception instanceof \Exception == false) {
		return $this->error('unknown exception format', response::STATUS_INTERNAL_SERVER_ERROR);
	}
	
	$exception_class = bootstrap::get_library('exception');
	
	$this->data['exception']['current'] = $exception;
	$this->data['exception']['current_trace_string'] = $exception_class::clean_paths(nl2br($exception->getTraceAsString()));
	
	$previous = $exception->getPrevious();
	if ($previous) {
		$this->data['exception']['previous'] = $previous;
		$this->data['exception']['previous_trace_string'] = $exception_class::clean_paths(nl2br($previous->getTraceAsString()));
	}
	
	$reason = $exception->getMessage();
	$code   = $exception->getCode();
	$this->error($reason, $code, $user_message);
}
1037733
protected function createJsonResponseForException(UserException $exception)
    {
        $message = $exception->getMessage();
        $statusCode = $exception->getStatusCode();
        $content = ['error' => str_replace('"', '\'', $message)];

        return new JsonResponse($content, $statusCode);
    }
908706
private function processExceptionContext(Exception $exception, array $context)
    {
        foreach($this->getExceptionHandlerMethods($exception) as $method) {
            $context = $this->{$method->getName()}($exception, $context);
        }

        return $context;
    }
858248
protected function processApiClientException(
        ApiClientException $exception,
        RequestInterface $request
    ): ResponseInterface {
        if (!$exception instanceof UnauthorizedException) {
            throw $exception;
        }

        $this->clearAuthorizationToken();
        $promise = $this->createPromiseForRequest($request, false);
        return $promise->wait();
    }
1198917
public function handleTaskException(\Throwable $userException, $value)
    {
        try {
            if (!empty($this->routine) && $this->routine instanceof \Generator) {
                $this->routine->throw($userException);
            }
        } catch (\Throwable $noCatchUserException) {
            if ($this->stack->isEmpty()) {
                try {
                    throw $noCatchUserException;
                } catch (\Throwable $noCatch) {
                    if ($this->controller) {
                        $this->controller->onExceptionHandle($noCatch);
                    } else {
                        throw $noCatch;
                    }
                }

                return true;
            }

            $noCatchException = null;
            while (!$this->stack->isEmpty()) {
                $this->routine = $this->stack->pop();
                try {
                    $this->routine->throw($noCatchUserException);
                    break;
                } catch (\Throwable $e) {
                    if ($this->stack->isEmpty()) {
                        $noCatchException = $noCatchUserException;
                    }
                }
            }

            if ($this->stack->isEmpty() && $noCatchException !== null && $this->controller) {
                $this->controller->onExceptionHandle($noCatchException);
            }
        }

        return true;
    }
217246
protected function prepareReplacements(Exception $exception)
    {
        // Run parent
        $replacements = parent::prepareReplacements($exception);

        // Format error message field keys
        if ($exception instanceof \Illuminate\Validation\ValidationException) {
            $replacements = $this->formatCaseOfValidationMessages($replacements);
        }

        // Format response object keys
        $updatedFormat = [];
        foreach ($this->format as $key => $value) {
            $updatedFormat[APIBoilerplate::formatKeyCaseAccordingToReponseFormat($key)] = $value;
        }
        $this->format = $updatedFormat;

        return $replacements;
    }
22208
private function collectException(HttpAdapterInterface $httpAdapter, HttpAdapterException $exception)
    {
        $request = $this->getTimer()->stop($exception->getRequest());

        $this->datas['exceptions'][] = [
            'adapter'   => $httpAdapter->getName(),
            'exception' => $this->getFormatter()->formatException($exception),
            'request'   => $this->getFormatter()->formatRequest($request),
            'response'  => $exception->hasResponse()
                ? $this->getFormatter()->formatResponse($exception->getResponse())
                : null,
        ];

        return $request;
    }
772599
public function convert(\Exception $ex)
    {
        $exceptions = array();

        do {
            $exceptions[] = $this->convertException($ex);
        } while (null !== $ex = $ex->getPrevious());

        return $exceptions;
    }
1293492
public function handleAndResponseException(\Exception $ex)
    {

        $response = '';
        switch (true) {
            case $ex instanceof \Illuminate\Database\Eloquent\ModelNotFoundException:
                $response = $this->respondNotFound('Record not found');
                break;
            case $ex instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
                $response = $this->respondNotFound("Not found");
                break;
            case $ex instanceof \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException:
                $response = $this->respondForbidden("Access denied");
                break;
            case $ex instanceof \Symfony\Component\HttpKernel\Exception\BadRequestHttpException:
                $response = $this->respondBadRequest("Bad request");
                break;
            case $ex instanceof BadMethodCallException:
                $response = $this->respondBadRequest("Bad method Call");
                break;
            case $ex instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException:
                $response = $this->respondForbidden("Method not found");
                break;
            case $ex instanceof \Illuminate\Database\QueryException:
                $response = $this->respondValidationError("Some thing went wrong with your query", [$ex->getMessage()]);
                break;
            case $ex instanceof \Illuminate\Http\Exceptions\HttpResponseException:
                $response = $this->respondInternalError("Something went wrong with our system", [$ex->getMessage()]);
                break;
            case $ex instanceof \Illuminate\Auth\AuthenticationException:
                $response = $this->respondUnauthorized("Unauthorized request");
                break;
            case $ex instanceof \Illuminate\Validation\ValidationException:
                $response = $this->respondValidationError("In valid request", [$ex->getMessage()]);
                break;
            case $ex instanceof NotAcceptableHttpException:
                $response = $this->respondUnauthorized("Unauthorized request");
                break;
            case $ex instanceof \Illuminate\Validation\UnauthorizedException:
                $response = $this->respondUnauthorized("Unauthorized request", [$ex->getMessage()]);
                break;
            case $ex instanceof \Exception:
                $response = $this->respondInternalError("Something went wrong with our system", [$ex->getMessage()]);
                break;
        }
        return $response;
    }
1254212
public static function handleException(\Exception $exception) {
        $context = [];
        $second  = null;

        try {
            $context['class'    ] = __CLASS__;
            $context['file'     ] = $exception->getFile();  // If the location is not preset the logger will resolve the
            $context['line'     ] = $exception->getLine();  // exception handler as the originating location.
            $context['unhandled'] = true;

            Logger::log($exception, L_FATAL, $context);     // log with the highest level
        }

        // Exceptions thrown from within the exception handler will not be passed back to the handler again. Instead the
        // script terminates with an uncatchable fatal error.
        catch (\Exception $second) {
            $indent = ' ';                                  // the application is crashing, last try to log

            // secondary exception
            $msg2  = '[FATAL] Unhandled '.trim(DebugHelper::composeBetterMessage($second)).NL;
            $file  = $second->getFile();
            $line  = $second->getLine();
            $msg2 .= $indent.'in '.$file.' on line '.$line.NL.NL;
            $msg2 .= $indent.'Stacktrace:'.NL.$indent.'-----------'.NL;
            $msg2 .= DebugHelper::getBetterTraceAsString($second, $indent);

            // primary (the causing) exception
            if (isset($context['cliMessage'])) {
                $msg1 = $context['cliMessage'];
                if (isset($context['cliExtra']))
                    $msg1 .= $context['cliExtra'];
            }
            else {
                $msg1  = $indent.'Unhandled '.trim(DebugHelper::composeBetterMessage($exception)).NL;
                $file  = $exception->getFile();
                $line  = $exception->getLine();
                $msg1 .= $indent.'in '.$file.' on line '.$line.NL.NL;
                $msg1 .= $indent.'Stacktrace:'.NL.$indent.'-----------'.NL;
                $msg1 .= DebugHelper::getBetterTraceAsString($exception, $indent);
            }

            $msg  = $msg2.NL;
            $msg .= $indent.'caused by'.NL;
            $msg .= $msg1;
            $msg  = str_replace(chr(0), '?', $msg);         // replace NUL bytes which mess up the logfile

            if (CLI)                                        // full second exception
                echo $msg.NL;
            error_log(trim($msg), ERROR_LOG_DEFAULT);
        }

        // web: prevent an empty page
        if (!CLI) {
            try {
                if (Application::isAdminIP() || ini_get_bool('display_errors')) {
                    if ($second) {                          // full second exception, full log location
                        echoPre($second);
                        echoPre('error log: '.(strlen($errorLog=ini_get('error_log')) ? $errorLog : 'web server'));
                    }
                }
                else echoPre('application error (see error log)');
            }
            catch (\Exception $third) {
                echoPre('application error (see error log)');
            }
        }
    }
856773
public function handleException(ServerRequestInterface $request, ResponseInterface $response, Exception $exception)
    {
        if ($level = $this->shouldLog('error')) {
            $this->logError($exception, $level);
        }

        return $this->handler->handleException($request, $response, $exception);
    }
1358547
protected function createResponseData(Exception $exception)
    {
        return $this->debug
            ? $this->extractExceptionData($exception)
            : $this->createDefaultResponseData($exception);
    }
886269
public function handle(Exception $exception, ServerRequestInterface $request, ResponseInterface $response, array $options = [])
    {
        $options += $this->defaultOptions;

        if (!$this->checkException($exception, $options['exceptions'])) {
            throw $exception;
        }

        $url = $this->getUrl($request, $options);

        return $response
                ->withHeader('Location', $url)
                ->withStatus($options['statusCode']);
    }
33774
public function exceptionHandler(Exception $ex)
    {
        return $this->errorHandler(E_USER_ERROR, $ex->getMessage(), $ex->getFile(), $ex->getLine());
    }