Example #1
0
File: error.php Project: neves/qi
	/**
	* Exception Handler
	* @todo tratar exceptions que não sejam Qi_Ex*
	* @todo mostrar se foi warning, notice, etc
	* @todo logar no arquivo error_log
	*/
	public static function exception_handler(Exception $exception)
	{
		if( ob_get_level() > 0 ) ob_end_clean();
		header("Content-Type: text/plain");
		echo $_SERVER["REQUEST_URI"]."\n"; // @TODO: colocar o caminho todo e fazer a versão MS-DOS
		echo sprintf("\n[%s]\n", $exception->getMessage());
		$traces = $exception instanceof Qi_Ex 
				  ? $exception->getTraceFiltrado() 
				  : $exception->getTrace();
		foreach($traces as $trace):
			$linha = $trace["line"];
			$arquivo = $trace["file"];
			echo sprintf("\n[%3d - %s]\n", $linha, $arquivo);
			echo str_repeat("-", 79);
			echo "\n";
			echo trim(self::extrair_codigo_fonte($arquivo, $linha, 1, 1));
			//echo "\n";
			//echo str_repeat("+", 79);
			echo "\n\n";
		endforeach;
	}