src/Phug/Formatter.php
public function getDebugError($error, $code, $path = null)
    {
        /** @var \Throwable $error */
        $line = $this->getSourceLine($error);
        if ($line === false) {
            return $error;
        }
        $source = explode("\n", $code, max(2, $line));
        array_pop($source);
        $source = implode("\n", $source);
        $pos = mb_strrpos($source, 'PUG_DEBUG:');
        if ($pos === false) {
            throw $error;
        }
        $nodeId = intval(mb_substr($source, $pos + 10, 32));
        if (!$this->debugIdExists($nodeId)) {
            throw $error;
        }
        $node = $this->getNodeFromDebugId($nodeId);
        $nodeLocation = $node->getSourceLocation();
        $location = new SourceLocation(
            ($nodeLocation ? $nodeLocation->getPath() : null) ?: $path,
            $nodeLocation ? $nodeLocation->getLine() : 0,
            $nodeLocation ? $nodeLocation->getOffset() : 0,
            $nodeLocation ? $nodeLocation->getOffsetLength() : 0
        );
        $className = $this->getOption('located_exception_class_name');

        return new $className(
            $location,
            $error->getMessage(),
            $error->getCode(),
            $error
        );
    }
public function getDebugError($error, $code, $path = null)
    {
        /** @var \Throwable $error */
        $line = $this->getSourceLine($error);
        if ($line === false) {
            return $error;
        }
        $source = explode("\n", $code, max(2, $line));
        array_pop($source);
        $source = implode("\n", $source);
        $pos = mb_strrpos($source, 'PUG_DEBUG:');
        if ($pos === false) {
            throw $error;
        }
        $nodeId = intval(mb_substr($source, $pos + 10, 32));
        if (!$this->debugIdExists($nodeId)) {
            throw $error;
        }
        $node = $this->getNodeFromDebugId($nodeId);
        $nodeLocation = $node->getSourceLocation();
        $location = new SourceLocation(
            ($nodeLocation ? $nodeLocation->getPath() : null) ?: $path,
            $nodeLocation ? $nodeLocation->getLine() : 0,
            $nodeLocation ? $nodeLocation->getOffset() : 0,
            $nodeLocation ? $nodeLocation->getOffsetLength() : 0
        );
        $className = $this->getOption('located_exception_class_name');

        return new $className(
            $location,
            $error->getMessage(),
            $error->getCode(),
            $error
        );
    }
public function getDebugError ( $ error , $ code , $ path = null ) { /** @var \Throwable $error */ $ line = $ this -> getSourceLine ( $ error ) ; if ( $ line === false ) { return $ error ; } $ source = explode ( "\n" , $ code , max ( 2 , $ line ) ) ; array_pop ( $ source ) ; $ source = implode ( "\n" , $ source ) ; $ pos = mb_strrpos ( $ source , 'PUG_DEBUG:' ) ; if ( $ pos === false ) { throw $ error ; } $ nodeId = intval ( mb_substr ( $ source , $ pos + 10 , 32 ) ) ; if ( ! $ this -> debugIdExists ( $ nodeId ) ) { throw $ error ; } $ node = $ this -> getNodeFromDebugId ( $ nodeId ) ; $ nodeLocation = $ node -> getSourceLocation ( ) ; $ location = new SourceLocation ( ( $ nodeLocation ? $ nodeLocation -> getPath ( ) : null ) ? : $ path , $ nodeLocation ? $ nodeLocation -> getLine ( ) : 0 , $ nodeLocation ? $ nodeLocation -> getOffset ( ) : 0 , $ nodeLocation ? $ nodeLocation -> getOffsetLength ( ) : 0 ) ; $ className = $ this -> getOption ( 'located_exception_class_name' ) ; return new $ className ( $ location , $ error -> getMessage ( ) , $ error -> getCode ( ) , $ error ) ; }
Return a formatted error linked to pug source.

@param \Throwable $error
@param string     $code
@param string     $path

@throws \Throwable

@return LocatedException|\Throwable
Return a formatted error linked to pug source .