Listens for exception events, and automatically logs them.

@param Exception $e
485445
public function exception($e)
    {
        $logLevel = \Psr\Log\LogLevel::CRITICAL;
        if ($e instanceof \Sabre\DAV\Exception) {
            // If it's a standard sabre/dav exception, it means we have a http
            // status code available.
            $code = $e->getHTTPCode();

            if ($code >= 400 && $code < 500) {
                // user error
                $logLevel = \Psr\Log\LogLevel::INFO;
            } else {
                // Server-side error. We mark it's as an error, but it's not
                // critical.
                $logLevel = \Psr\Log\LogLevel::ERROR;
            }
        }

        $this->server->getLogger()->log(
            $logLevel,
            'Uncaught exception',
            [
                'exception' => $e,
            ]
        );
    }
740280
protected function addError(Exception $e) {
        $errors = $this->getErrors();
        $errors[] = $e;
        $this->setErrors($errors);
    }
300901
public function report(Exception $e)
    {
        if ($this->exceptionHandler !== null) {
            $this->exceptionHandler->report($e);
        }
    }
959828
function logexception(\Exception $exception) {
		try {
			$message = $exception->getMessage();
			$trace = $exception->getTraceAsString();
			$trace = $this->becloud($trace);
			$trace = str_replace("\n", "\n\t", trim($trace, " \n\r\t"));
			$this->log("$message\n\n\t$trace\n");
		}
		catch (\Exception $e) {
			$this->failedLogging($e, $exception->getMessage());
		}
	}
289753
public function error(\Exception $e)
    {
        if ($this->beep_on_error === true) {
            \Commando\Util\Terminal::beep();
        }

        if ($this->trap_errors !== true) {
            throw $e;
        }

        $color = new \Colors\Color();
        $error = sprintf('ERROR: %s ', $e->getMessage());
        echo $color($error)->bg('red')->bold()->white() . PHP_EOL;
        exit(1);
    }
885377
public function handleDbEvent($e) {
    $statement = $e->getParam('statement', null);
    if ($statement != null) {
      $this->statements[] = [$statement->getSql(), $statement->getParameterContainer()->getNamedArray()];
    }
  }
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;
        }
    }
971010
protected static function exception(Exception $e)
	{
		$logLevel = self::config('cache.exception.log', FALSE);
		if (FALSE !== $logLevel) {
			Kohana_Exception::log($e, $logLevel);
		}

		if (self::config('cache.exception.throw', FALSE)) {
			throw $e;
		};
	}
1268378
public static function handleError($e)
    {
        if (!defined('LEVEL_ENV')) {
            define('LEVEL_ENV', 3);
        }

        if (is_array($e)) {
            $e = new Exception('Error with : ' . json_encode($e));
        }

        if (LEVEL_ENV < 2) {
            Throw $e;
        }

        Log::error($e);
    }
654707
public function _handleException($e)
	{
		if(!$this->_inError && $handler = $this->_application->errorHandler())
		{
			$this->_inError = true;
			$handler->handle($e);
			$this->_inError = false;
		}
		else
		{
			if(php_sapi_name() == 'cli')
			{
				echo $e->__toString();
				exit(1);
			}
			else
			{
				header('HTTP/1.1 500 Internal Server Error');

				echo "<h1>Error: ".$e->getMessage().'</h1>';
				echo '<pre>'.$e->__toString().'</pre>';
				exit(1);
			}
		}
	}
814512
protected function handleError(Exception $e)
    {
        if($this->isCli){
            $errorCode = $e->getCode();
            exit((empty($errorCode)) ? 1 : $errorCode);	//exit the program with an error
        }
        else {
            throw new Exception($e->getMessage());
        }
    }
770019
public static function logException($e)
    {
        $previous = $e->getPrevious();
        $trace = $e->getTraceAsString();

        $logMessage = sprintf(
            "%s in %s at %s\n%s\nBacktrace:\n%s\n",
            get_class($e),
            $e->getFile(),
            $e->getLine(),
            $e->getMessage(),
            $trace
        );

        Eresus_Kernel::log(__METHOD__, LOG_ERR, $logMessage);

        if ($previous)
        {
            self::logException($previous, 'Previous exception:');
        }
    }
941225
public function logException($e) {
		if(!$this->isLogging())
			return;

		#PSRException with a given severity
		if($e instanceof PSRException) {
			$severity = $e->getseverity();
			$msg = $e->getMessage();
		}
		#PHP exception
		elseif($e instanceof \ErrorException) {
			$severity = static::getPHPErrorSeverity($e->getCode());
			$msg = 'PHP ('.static::getPHPError($e->getCode()).'): '.$e->getMessage();
		}
		#other exception
		else {
			$severity = \Psr\Log\LogLevel::ERROR;
			$msg = get_class($e).': '.$e->getMessage();
		}

		$trace = $this->getBacktraceFromException($e);

		$this->log($severity, $msg, $e->getFile(), $e->getLine(), $e, $trace);
	}
202315
private function handleExternalError(\Exception $e) {
        $reflection = new \ReflectionClass($e);
        echo '<header>';
            echo '<h1>Exception: ' . $reflection->getName() . '</h1>';
            echo '<h2>Message: ' . $e->getMessage() . '</h2>';
            echo '<h3>' . $e->getFile() . ':' . $e->getLine() . '</h3>';
        echo '</header>';
        if ( method_exists($e, 'getContext') ) {
            echo 'Debug:';
            !d( $e->getContext() );
        }
    }
643827
static function exceptionHandler($e) {
	    if(get_class($e) == 'PDOException'){
	        $err = $e->getMessage().'<br>code: '.$e->getCode();
	    } else {
	        $err = 
	        '<b>Code:</b>'.$e->getCode().'<br>'.
	        '<b>Message:</b> <i>'.$e->getMessage().'</i><br>'.
	        '<b>Thrown in: </b>'.$e->getFile().' ['.$e->getLine().']<br>'.
	        '<b>Stack trace:</b><pre>'.$e->getTraceAsString().'</pre>';
	        
	    }
	    exit($err);
	}
1151999
protected function reportException(Exception $e)
    {
        $handler = $this->app->make(ExceptionHandler::class);

        $handler->report($e);
    }
1099826
public function notify(Exception $e)
    {
        $this->exception = $e;
        $this->notifier->send($e);
    }