@param Exception $e

@return $this
160482
public static function render(Exception $e)
    {
        switch ($e->message) {
            case 1:
                $return = redirect()->back()->withErrors(['Not enough arguments provided']);
                break;
            case 2:
                $return = redirect()->back()->withErrors(['Object or argument is not valid']);
                break;
            case 3:
                $return = redirect()->back()->withErrors(["Object doesn't exist"]);
                break;
            case 4:
                $return = redirect()->back()->withErrors(['Object already exists']);
                break;
            case 5:
                $return = redirect()->back()->withErrors(['Object is suspended']);
                break;
            case 6:
                $return = redirect()->back()->withErrors(['Object is already unsuspended']);
                break;
            case 7:
                $return = redirect()->back()->withErrors(["Object can't be deleted because is used by the other object"]);
                break;
            case 8:
                $return = redirect()->back()->withErrors(['Object cannot be created because of hosting package limits']);
                break;
            case 9:
                $return = redirect()->back()->withErrors(['Wrong password']);
                break;
            case 10:
                $return = redirect()->back()->withErrors(['Object cannot be accessed be the user']);
                break;
            case 11:
                $return = redirect()->back()->withErrors(['Subsystem is disabled']);
                break;
            case 12:
                $return = redirect()->back()->withErrors(['Configuration is broken']);
                break;
            case 13:
                $return = redirect()->back()->withErrors(['Not enough disk space to complete the action']);
                break;
            case 14:
                $return = redirect()->back()->withErrors(['Server is to busy to complete the action']);
                break;
            case 15:
                $return = redirect()->back()->withErrors(['Connection failed. Host is unreachable']);
                break;
            case 16:
                $return = redirect()->back()->withErrors(['FTP server is not responding']);
                break;
            case 17:
                $return = redirect()->back()->withErrors(['Database server is not responding']);
                break;
            case 18:
                $return = redirect()->back()->withErrors(['RRDtool failed to update the database']);
                break;
            case 19:
                $return = redirect()->back()->withErrors(['Update operation failed']);
                break;
            case 20:
                $return = redirect()->back()->withErrors(['Service restart failed']);
                break;
            default:
                $return = redirect()->back()->withErrors([$e->getMessage()]);
        }

        return $return;
    }
551985
protected function prepareException(Exception $e)
    {
        if ($e instanceof ModelNotFoundException) {
            $e = new NotFoundHttpException($e->getMessage(), $e);
        } elseif ($e instanceof AuthorizationException) {
            $e = new AccessDeniedHttpException($e->getMessage(), $e);
        } elseif ($e instanceof TokenMismatchException) {
            $e = new HttpException(419, $e->getMessage(), $e);
        }

        return $e;
    }
875600
protected function convertDatabaseException(\Exception $e)
	{
		if($e instanceof DatabaseException)
		{
			return $e;
		}
		
		// Check for PDO exception in order to determine FK violation:
		$cause = $e;
		
		if(!$cause instanceof \PDOException)
		{
			while(NULL !== ($cause = $cause->getPrevious()))
			{
				if($cause instanceof \PDOException)
				{
					break;
				}
			}
		}
		
		if($cause instanceof \PDOException)
		{
			switch($this->driverName)
			{
				case DB::DRIVER_MYSQL:
					return $this->convertMySqlException($cause, $e);
				case DB::DRIVER_POSTGRESQL:
					return $this->convertPostgresException($cause, $e);
				case DB::DRIVER_SQLITE:
					return $this->convertSqliteException($cause, $e);
			}
		}
		
		return new DatabaseException($e->getMessage(), 0, $e);
	}
206663
private function handleForBrowser(Exception $e)
    {
//        $request = request();
//        if ($e instanceof ModelNotFoundException) {
//            $e = new NotFoundHttpException($e->getMessage(), $e);
//        }
//        elseif ($e instanceof AuthorizationException) {
//            $e = new HttpException(403, $e->getMessage());
//        }
//
//        if ($e instanceof HttpResponseException) {
//            return $e->getResponse();
//        }
//        if ($e instanceof AuthenticationException) {
//            header('Location: ' . url('auth/login'));
//            exit;
//        }
//        else if ($e instanceof ValidationException) {
//            return $this->convertValidationExceptionToResponse($e, $request);
//        }
//        else if ($request->isAjax() || $request->wantsJson()) {
//            /** @var HttpException $e */
//            return response()->json($e->getMessage(), $this->isHttpException($e) ? $e->getStatusCode() : 400);
//        }

        $data = $this->convertException($e);

        // set error title and subtitle

        if ($e instanceof HttpException) {
            // set the HTTP Response Status Text as error title
            $data['title'] = http_status_text($data['status']);

            // set the Exception class and the HTTP Response Status Code as subtitle
            $data['subtitle'] = get_class($e) . ', Status Code ' . $data['status'];
        }
        else if ($e instanceof QueryException) {
            // set title
            $data['title'] = 'SQL Error';

            // set the Exception class and error codes as subtitle
            $data['subtitle'] = get_class($e) . ' (Exception code: ' . $data['code'] . ')';
            if ($data['ansiCode'] !== null) {
                $data['subtitle'] .= ', ANSI SQLSTATE Error Code: ' . $data['ansiCode'];
            }
            if ($data['driverCode'] !== null) {
                $data['subtitle'] .= ', Driver-specific Error Code: ' . $data['driverCode'];
            }
        }
        else {
            // set error title
            $data['title'] = 'Error';

            // // set the Exception class and the Exception code as subtitle
            $data['subtitle'] = get_class($e) . ' (Exception code: ' . $data['code'] . ')';
        }

        // render the source code

        if ($e instanceof QueryException) {
            // parse the sql line from the message if exists
            if (preg_match('/at line (\d)$/', $data['message'], $match)) {
                $sqlLine = $match[1];
            }
            else {
                $sqlLine = 0;
            }
            // set the SQL Statement as source
            $data['source'] = $this->renderSQL($data['sql'], $sqlLine);
        }
        else {
            // set the PHP Code as source
            $data['source'] = $this->renderPHP($data['file'], $data['line']);
        }

        // render the trace

        $data['trace'] = $this->renderTrace($data['trace']);

        // strip the filename

        $data['file'] = $this->stripFile($data['file']);

        // choose the template

        $view = config('app.debug') ? 'errors.debug' : 'errors.default';
        if (!config('app.debug') && view()->exists('errors.' . $data['status'])) {
            $view = 'errors.' . $data['status'];
        }

        // send the response

        $headers = ($e instanceof HttpException) ? $e->getHeaders() : [];

        return response()->view($view, $data, $data['status'], $headers)->send();
    }
33774
public function exceptionHandler(Exception $ex)
    {
        return $this->errorHandler(E_USER_ERROR, $ex->getMessage(), $ex->getFile(), $ex->getLine());
    }
366730
public function on_exception( $e ) {

		// Log the PHP exception.
		do_action(
			\Inpsyde\Wonolog\LOG,
			new Log(
				$e->getMessage(),
				Logger::CRITICAL,
				Channels::PHP_ERROR,
				[
					'exception' => get_class( $e ),
					'file'      => $e->getFile(),
					'line'      => $e->getLine(),
					'trace'     => $e->getTraceAsString(),
				]
			)
		);

		// after logging let's reset handler and throw the exception
		restore_exception_handler();
		throw $e;
	}
479349
public function formatException(\Exception $e) {
        $xml = new XMLWriter();
        $xml->openMemory();
        $xml->writeElement('class', get_class($e));
        $xml->writeElement('message', htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8'));
        $xml->writeElement('file', htmlspecialchars($e->getFile(), ENT_QUOTES, 'UTF-8'));
        $xml->writeElement('line', $e->getLine());
        $xml->writeElement('trace', htmlspecialchars($e->getTraceAsString(), ENT_QUOTES, 'UTF-8'));

        return $xml->outputMemory();
    }
1285459
private function _exceptionHandler($e)
    {
        $this->_errorController->setParams(array('e' => $e));
        $action = FrontController::EXCEPTION_HANDLER_ACTION . 'Action';
        $this->_response->setStatusCode(500);

        return $this->_errorController->$action();
    }
1245937
protected function catchException(\Exception $e)
    {
        foreach ($this->onException as $call) {
            call_user_func_array($call, [$e]);
        }

        throw $e;
    }
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;
	}
18198
protected function handleHttpException(Exception $e)
    {
        $statusCode = $e->getStatusCode();

        // if there is no exception message just get the standard HTTP text.
        if (empty($e->getMessage())) {
            $message = Response::$statusTexts[$statusCode];
        } else {
            $message = $e->getMessage();
        }

        return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
    }
176705
public function throws(\Throwable $exception): self
    {
        $this->exception = $exception;
        $this->invalidate();

        return $this;
    }
1271557
public static function fromException($e)
    {
        if (is_subclass_of($e, self::class)) {
            return $e;
        }
        return new self($e->message, $e->code);
    }
1250093
public function andThrow($e)
    {
        if (! $e instanceof \Exception) {
            if (is_scalar($e) && class_exists($e) && is_a($e, '\Exception', true)) {
                $e = new $e("Generic message");
            } else {
                throw new \LogicException("Can only create exceptions on-the-fly with a scalar message");
            }
        }

        $this->andReturn(function() use ($e){
            if (! $e instanceof \Exception) {
                throw new \Exception($e);
            } else {
                throw $e;
            }
        });
        
        return $this;
    }
808489
protected function convertExceptionToResponse(Exception $e)
    {
        $e = FlattenException::create($e);
        $handler = new SymfonyExceptionHandler(DEBUG);
        echo $handler->getHtml($e);
    }
1289270
protected function handleException(\Exception $e)
    {
        $errors = [];

        $scannedException = $e;
        while ($scannedException) {
            $errors[] = $scannedException->getMessage();
            $errors[] = 'In ' . $scannedException->getFile() . ' on line ' . $scannedException->getLine();
            $scannedException = $scannedException->getPrevious();
        }

        return $this->notify($errors, 'error');
    }
769737
public function report(Exception $e)
    {
        if ($this->shouldntReport($e)) {
            return;
        }

        if (method_exists($e, 'report')) {
            return $e->report();
        }

        try {
            $logger = $this->container->make(LoggerInterface::class);
        }
        catch (Exception $ex) {
            throw $e; // Throw the original exception
        }

        $logger->error($e);
    }