异常的回调

@param \Throwable $e 异常实例
@throws \Throwable
491625
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);
            if ($this->getContext()->getOutput()) {
                $this->output('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));
        }
    }
1001099
public function addException($e)
    {
        if ($e instanceof \Exception) {
            try {
                $this->bar->getCollector('exceptions')->addException($e);
            } catch (\Exception $ie) {
            } // mute exceptions there
        }
    }
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);
    }
1245937
protected function catchException(\Exception $e)
    {
        foreach ($this->onException as $call) {
            call_user_func_array($call, [$e]);
        }

        throw $e;
    }
281961
public function throwServiceException(\Throwable $exception)
    {
        $exceptionClass = ExceptionInterface::class;

        if (method_exists($exception, 'getFaultCode')) {
            $exceptionClass = $this->getServiceException($exception->getFaultCode());
        }
        if ($exceptionClass !== ExceptionInterface::class) {
            throw new $exceptionClass($exception->getMessage());
        }

        throw new ServerException('Unknown error occurred', 0, $exception);
    }
651100
public function render( \Throwable $e )
    {
        list( $file, $line ) = Util::caller(0);

        $title = 'CharcoalPHP: Exception List';

        if ( $this->clear_buffer ){
            ob_clean();
        }

        echo $this->_output( $e, $title, $file, $line );
    }
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);
		}
	}
300901
public function report(Exception $e)
    {
        if ($this->exceptionHandler !== null) {
            $this->exceptionHandler->report($e);
        }
    }
327085
public function report(Exception $e)
    {
        if ($this->shouldntReport($e)) {
            return;
        }

        if (is_callable($reportCallable = [$e, 'report'])) {
            return $this->container->call($reportCallable);
        }

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

        $logger->error(
            $e->getMessage(),
            array_merge($this->context(), ['exception' => $e]
        ));
    }
993779
protected function handleBeginTransactionException($e)
    {
        if ($this->causedByLostConnection($e)) {
            $this->reconnect();

            $this->pdo->beginTransaction();
        } else {
            throw $e;
        }
    }
51082
public function report( Exception $e )
	{
		if ( !$this->shouldReport( $e ) )
			return;

		try
		{
			$logger = Framework::log();
		}
		catch ( Exception $ex )
		{
			throw $e; // throw the original Exception
		}

		$logger->error( $e );


		$level = $this->getLevel( $e );
		$id = UniversalBuilder::resolveClass( ExceptionIdentifier::class )->identify( $e );

		$logger->{$level}( $e, ['identification' => ['id' => $id]] );
	}
914927
public function handle(EventParam $e)
    {
        // Aop 配置注入
        foreach(Helper::getMains() as $main)
        {
            $this->parseConfigs($main->getConfig()['aop'] ?? []);
        }
    }
890155
public function handleException( \Throwable $e ) : bool
    {
        // Render exception
        $output = $this->renderer->output( $e );
    
        // output
        fwrite(STDERR, $output . PHP_EOL);
    
        return true;
    }
380006
public function printTrace(\Throwable $e)
    {
        $eClass = \get_class($e);

        $this->writer->colors(
            "{$eClass} <red>{$e->getMessage()}</end><eol/>" .
            "(thrown in <yellow>{$e->getFile()}</end><white>:{$e->getLine()})</end>"
        );

        // @codeCoverageIgnoreStart
        if ($e instanceof Exception) {
            // Internal exception traces are not printed.
            return;
        }
        // @codeCoverageIgnoreEnd

        $traceStr = '<eol/><eol/><bold>Stack Trace:</end><eol/><eol/>';

        foreach ($e->getTrace() as $i => $trace) {
            $trace += ['class' => '', 'type' => '', 'function' => '', 'file' => '', 'line' => '', 'args' => []];
            $symbol = $trace['class'] . $trace['type'] . $trace['function'];
            $args   = $this->stringifyArgs($trace['args']);

            $traceStr .= "  <comment>$i)</end> <red>$symbol</end><comment>($args)</end>";
            if ('' !== $trace['file']) {
                $file      = \realpath($trace['file']);
                $traceStr .= "<eol/>     <yellow>at $file</end><white>:{$trace['line']}</end><eol/>";
            }
        }

        $this->writer->colors($traceStr);
    }
573273
public function canReport(Throwable $e): bool
    {
        $level = $this->getLogLevel($e);

        // TODO : utiliser la méthode shouldLog():bool
        return $this->logLevels[$level] <= $this->logLevels[$this->logLevelThreshold];
    }
407601
public function exception($e)
    {
        $this->setParams(
            $e->getCode(),
            $e->getMessage(),
            $e->getFile(),
            $e->getLine(),
            $e->getTraceAsString());

        return $this->render();
    }
138292
protected function _handleGETPOSTException(\Throwable $e)
    {
        header("Content-Type: text/html; charset=utf-8");

		// get exception string (stack trace)
		$ex = $this->_getException($e, 'Error during request');
		
        echo '<!DOCTYPE html><html><body>';

		// reset css and adapt font-size according to display width
        echo <<<HTML
<style>

	body{
		font-size:1em;		
	}
	
	
	/* width>1400 : larger font */
	@media screen and (min-width:1400px) {
		body {
			font-size:1.1em;
		}
	}

	
	/* width < 800 : mobile screen, smaller font */
	@media screen and (max-width:800px) {
		body {
			font-size:0.6em;
		}
	}
</style>

HTML;

		echo $ex;
		
		// mobile link
		echo $this->_mobileLink($ex);
		echo '</body></html>';
    }