Handle the given exception.

@param  mixed  $passable
@param  \Exception  $e
@return mixed

@throws \Exception
339521
protected function handleException($passable, Exception $e)
    {
        if (! $this->container->bound(ExceptionHandler::class) ||
            ! $passable instanceof Request) {
            throw $e;
        }

        $handler = $this->container->make(ExceptionHandler::class);

        $handler->report($e);

        $response = $handler->render($passable, $e);

        if (method_exists($response, 'withException')) {
            $response->withException($e);
        }

        return $response;
    }
395753
public static function exceptionHandler(\Throwable $exception, bool $exit = true): void
    {
        if (!self::$reserved && $exit) {
            return;
        }
        self::$reserved = null;

        Helpers::improveException($exception);
        self::removeOutputBuffers(true);

        if (self::isProductionMode()) {
            try {
                self::log($exception, self::getExceptionLevel($exception));
            } catch (\Throwable $e) {
            }

            $message = 'ERROR: application encountered an error and can not continue. '
                . (isset($e) ? "Unable to log error.\n" : "Error was logged.\n");

            if (PHP_SAPI === 'cli') {
                \fwrite(STDERR, $message);
            } else {
                echo $message;
            }
        } else {
            $level = self::getExceptionLevel($exception);
            self::chromeLog($exception, $level);

            try {
                $file = self::log($exception, $level);

                echo "$exception\n" . ($file ? "(stored in $file)\n" : '');
                if ($file && PHP_SAPI === 'cli') {
                    if (self::$browser) {
                        \exec(self::$browser . ' ' . \escapeshellarg($file));
                    } elseif (DIRECTORY_SEPARATOR === '\\') {
                        \exec(\escapeshellarg($file));
                    } elseif (strtoupper(PHP_OS) === 'DARWIN') {
                        \exec('open ' . \escapeshellarg($file));
                    }
                }
            } catch (\Throwable $e) {
                echo "$exception\nUnable to log error: {$e->getMessage()}\n";
            }
        }

        if ($exit) {
            exit(255);
        }
    }
890155
public function handleException( \Throwable $e ) : bool
    {
        // Render exception
        $output = $this->renderer->output( $e );
    
        // output
        fwrite(STDERR, $output . PHP_EOL);
    
        return true;
    }
862838
protected function handleViewException( Throwable $e )
	{
		$e = new ErrorException( $this->getMessage( $e ), 0, 1, $e->getFile(), $e->getLine(), $e );

		parent::handleViewException( $e );
	}
1002705
public function handleException(\Throwable $e)
	{
        // headers sent by browser are prefixed with 'HTTP' (so that they don't mess with environment variables), and - are replaced by _
        if ( (strpos($_SERVER['HTTP_USER_AGENT'], 'XMLHTTP') === 0) || (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') === 0) )
            // if XMLHTTP request
            $this->_handleXMLHTTPCommandException($e);

        // if GET/POST request
        else
            $this->_handleGETPOSTException($e);
        
        die();
    }
32040
protected function handlePhpError(Throwable $e)
    {
        $handler = 'phpErrorHandler';
        $params = [$e];

        if ($this->getContainer()->has($handler)) {
            $callable = $this->getContainer()->get($handler);
            // Call the registered handler
            return call_user_func_array($callable, $params);
        }

        // No handlers found, so just display simple error
        $this->displayError($e->getMessage());
        exit($e->getCode() ?: 1);
    }
909369
public function handleUncaughtException(\Throwable $exception)
    {
        try {
            Registry::getLogger()->error(
                $exception->getMessage(),
                [$exception]
            );
        } catch (\Throwable $loggerException) {
            /**
             * Logger is broken because of exception.
             * Throw original exception in order to show the root cause of a problem.
             */
        }

        if ($this->_iDebug || defined('OXID_PHP_UNIT')) {
            throw $exception;
        } else {
            $this->displayOfflinePage();
            $this->exitApplication();
        }
    }
257898
protected function handleException($passable, Exception $e)
    {
        if (! $this->container->bound(ExceptionHandlerContract::class) ||
            ! $passable instanceof DataProviderContract) {
            throw $e;
        }

        $handler = $this->container->make(ExceptionHandlerContract::class);

        $handler->report($e);

        $response = $handler->render($passable, $e);

        if (method_exists($response, 'withException')) {
            $response->withException($e);
        }

        return $response;
    }
292029
protected function editActionException(\Exception $e)
    {
        $this->handleException($e);
        $id = $this->get('request')->get($this->admin->getIdParameter());
        $object = $this->admin->getObject($id);

        return $this->redirectTo($object);
    }
877048
protected function handleException($e)
    {
        if (isset($this->exceptions)) {
            $this->exceptions->report($e);
        }

        if ($this->causedByLostConnection($e)) {
            $this->shouldQuit = true;
        }
    }
1237517
protected function handleError(\Exception $e) {
		$kernel = $this->getDefaultKernel();
		$application = $this->getDefaultApplication($kernel);

		$kernel->getResponse()->addValue("error", $e->getMessage());
		$this->logger->logError($e->getMessage());

		return $application;
	}
1129877
protected function handleViewException($e)
	{
		$e = new \ErrorException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e);

		ob_get_clean(); throw $e;
	}
1303570
protected function handleException(Exception $e)
    {
        $handler = $this->app->make(ExceptionHandler::class);

        $handler->report($e);

        try {
            $handler->renderForConsole(
                $this->app->make(OutputInterface::class), $e
            );
        } catch (Throwable $e) {
            //
        }
    }
340649
public function handleException($e)
    {
        if (!$e instanceof Exception) { // Since PHP 7, in addition to an Exception, an internal Error may occur.
            // Convert the Error to ErrorException
            $e = new ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); // @codeCoverageIgnore
        } // @codeCoverageIgnore

        $this->getExceptionHandler()->handle($e);
    }
1230389
protected function handleException(Exception $e)
    {
        // if ($e instanceof MethodNotAllowedException) {
        //     $handler = 'notAllowedHandler';
        //     $params = [$e->getRequest(), $e->getResponse(), $e->getAllowedMethods()];
        // } elseif ($e instanceof NotFoundException) {
        //     $handler = 'notFoundHandler';
        //     $params = [$e->getRequest(), $e->getResponse(), $e];
        // } elseif ($e instanceof SlimException) {
        //     // This is a Stop exception and contains the response
        //     return $e->getResponse();
        // } else {
            // Other exception, use $request and $response params
            $handler = 'errorHandler';
            $params = [$e];
        // }

        if ($this->getContainer()->has($handler)) {
            $callable = $this->getContainer()->get($handler);
            // Call the registered handler
            return call_user_func_array($callable, $params);
        }

        // No handlers found, so just display simple error
        $this->displayError($e->getMessage());
        exit($e->getCode() ?: 1);
    }
12935
public function throws(\Throwable $e): self
    {
        $this->callMap = new CallMap(['function' => throws($e)]);
        return $this;
    }
267240
public function exceptionHandler($e) {
        if (method_exists($e, 'getType')) {
            $this->addError($e->getMessage(), $e->getFile(), $e->getLine(), $e->getType());
        }
        else {
            $this->addError($e->getMessage(), $e->getFile(), $e->getLine(), gettype($e));
        }
    }