Wire::___trackException PHP 메소드

___trackException() 공개 메소드

It will log Exception to exceptions.txt log if 'exceptions' is in $config->logs. It will re-throw Exception if $config->allowExceptions == true. If additioanl $text is provided, it will be sent to $this->error when $fatal or $this->warning otherwise.
public ___trackException ( Exception $e, boolean | integer $severe = true, string | array | object | true $text = null )
$e Exception Exception object that was thrown
$severe boolean | integer Whether or not it should be considered severe (default=true)
$text string | array | object | true Additional details (optional). When provided, it will be sent to $this->error($text) if $severe==true, or $this->warning($text) if $severe==false. Specify boolean true to just sent the $e->getMessage() to $this->error() or $this->warning().
    public function ___trackException(Exception $e, $severe = true, $text = null)
    {
        $config = $this->wire('config');
        $log = $this->wire('log');
        $msg = $e->getMessage();
        if ($text !== null) {
            if ($text === true) {
                $text = $msg;
            }
            $severe ? $this->error($text) : $this->warning($text);
            if (strpos($text, $msg) === false) {
                $msg = "{$text} - {$msg}";
            }
        }
        if (in_array('exceptions', $config->logs) && $log) {
            $msg .= " (in " . str_replace($config->paths->root, '/', $e->getFile()) . " line " . $e->getLine() . ")";
            $log->save('exceptions', $msg);
        }
        if ($severe && $this->wire('config')->allowExceptions) {
            throw $e;
            // re-throw, if requested
        }
        return $this;
    }