An exception handler, per the documentation in PHP. This function is
also used for the handling of errors, even when they are non-blocking.

@param \Exception $e
504642
public function exceptionHandler($e)
    {
        http_response_code(500);

        $e = $this->runHandlers($e);

        if (!$this->silenceErrors) {
            $formattedResponse = $this->runFormatters($e);
            print $formattedResponse;
        }

        if ($this->silenceErrors &&
            isset($this->errorPage) &&
            !($e instanceof ErrorException)
        ) {
            ob_start();
            $response = $this->errorPage->format($e);
            ob_end_clean();
            print $response;
            return;
        }
    }
1090346
public function handle($e)
	{
		$this->logException($e);

		if ($this->isExceptionHalting($e))
		{
			if (ob_get_contents() !== false) ob_end_flush();
			if($this->_showStackTrace) echo "\n".$e->__toString()."\n\n";
			exit(self::EXIT_CODE);
		}
	}
924965
public function handle($e)
	{
		$this->logException($e);

		if ($this->isExceptionHalting($e))
		{
			// if headers are sent, we can't send a response
			if(headers_sent())
			{
				echo $this->buildResponseBody($e);
				exit(0);
			}

			// send it off
			$sender = new Http\ResponseSender($this->buildResponse($e));
			$sender->send();

			if (ob_get_level() > 0) ob_flush();
			exit(self::EXIT_CODE);
		}
	}
246097
public function handleException($ex)
    {
        if ($ex instanceof \Exception || $ex instanceof \Throwable) {
            throw new \ErrorException($ex->getMessage(), $ex->getCode(), E_ALL, $ex->getFile(), $ex->getLine());
        }
    }
1078313
public function exceptionHandler($e) : void
    {
        $this->setError(
            (int) $e->getCode(),
            (string) $e->getMessage(),
            (string) $e->getFile(),
            (int) $e->getLine(),
            (string) get_class($e),
            $e->getTrace()
        );

        View::render('500.php', (object) $this->errors);
    }
1343335
private function handleError($exception)
    {
        if ($this->errorCallback !== null) {
            $callback = $this->errorCallback;
            $callback($exception);
        }
    }
407601
public function exception($e)
    {
        $this->setParams(
            $e->getCode(),
            $e->getMessage(),
            $e->getFile(),
            $e->getLine(),
            $e->getTraceAsString());

        return $this->render();
    }
911614
private function wrapException(\Exception $e)
    {
        if ($e instanceof ClientException && $e->getResponse()->getStatusCode() == 404) {
            return NotFoundException::wrap($e);
        }

        return ErrorException::wrap($e);
    }
844262
protected function handleException($request, Exception $e)
    {
        $handler = $this->app->make(ExceptionHandler::class);

        return $handler->render($request, $e);
    }
862838
protected function handleViewException( Throwable $e )
	{
		$e = new ErrorException( $this->getMessage( $e ), 0, 1, $e->getFile(), $e->getLine(), $e );

		parent::handleViewException( $e );
	}
379732
public function caughtException($e)
    {
        $this->hook('caught-exception', array($e));
        echo get_class($e), ': '.$e->getMessage();
        exit;
    }
300901
public function report(Exception $e)
    {
        if ($this->exceptionHandler !== null) {
            $this->exceptionHandler->report($e);
        }
    }
983710
public function handleException($exception)
    {
        $isHandled = false;
        try {
            $isHandled = $this->handler->handle($exception);
        } catch (Exception $ex) {
        } catch (Throwable $ex) {
        }

        // Bomb out if handler returns true, since was able to render something to the client
        if ($isHandled) {
            exit;
        }

        // Rethrow to be handled by default php exception handling.
        throw $exception;
    }
308183
public function exceptionHandler($e) {
		static::$reservedMemory = null;

		$this->logException($e);

		if(!headers_sent())
			http_response_code(500);

		if($this->display) {
			if($this->debug) {
				$trace = $this->getBacktraceFromException($e);

				if($e instanceof PSRException)
					$msg = $e->getMessage();
				elseif($e instanceof \ErrorException)
					$msg = 'PHP ('.static::getPHPError($e->getCode()).'): '.$e->getMessage();
				else
					$msg = get_class($e).': '.$e->getMessage();

				$result = '';
				if($msg)
					$result .= $msg."\n\n";
				$result .= Debug::getReport($trace);
				echo $result;
			}
			else
				echo 'Something went wrong.';
		}
	}
634859
public function onExceptionHandle(\Throwable $e)
    {
        try {
            if ($e->getPrevious()) {
                $ce = $e->getPrevious();
                $errMsg = dump($ce, false, true);
            } else {
                $errMsg = dump($e, false, true);
                $ce = $e;
            }

            $this->getContext()->getLog()->error($errMsg);
            $this->outputJson(parent::$stdClass, 'Internal Server Error', 500);
        } catch (\Throwable $ne) {
            getInstance()->log->error('previous exception ' . dump($ce, false, true));
            getInstance()->log->error('handle exception ' . dump($ne, false, true));
        }
    }
749347
public static function log(Exception $e)
    {
        Base::getLog()->error($e->getMessage(), [
            'code' => $e->getCode(),
            'file' => $e->getFile(),
            'line' => $e->getLine(),
        ]);
    }
506024
public static function exception_handler(\Exception $e)
	{
		if (method_exists($e, 'handle'))
		{
			return $e->handle();
		}

		$severity = ( ! isset(static::$levels[$e->getCode()])) ? $e->getCode() : static::$levels[$e->getCode()];
		logger(\Fuel::L_ERROR, $severity.' - '.$e->getMessage().' in '.$e->getFile().' on line '.$e->getLine());

		if (\Fuel::$env != \Fuel::PRODUCTION)
		{
			static::show_php_error($e);
		}
		else
		{
			static::show_production_error($e);
		}
	}