Documentation

Error extends Exception
in package

Twig base exception.

This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).

To help debugging template issues, this class tracks the original template name and line where the error occurred.

Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

Properties

$lineno  : mixed
$phpFile  : string
$phpLine  : int
$rawMessage  : mixed
$source  : Source|null

Methods

__construct()  : mixed
Constructor.
appendMessage()  : void
getRawMessage()  : string
getSourceContext()  : Source|null
getTemplateLine()  : int
guess()  : void
setSourceContext()  : void
setTemplateLine()  : void
guessTemplateInfo()  : void
updateRepr()  : void

Properties

$lineno

private mixed $lineno

$phpFile

private string $phpFile

$phpLine

private int $phpLine

$rawMessage

private mixed $rawMessage

Methods

__construct()

Constructor.

public __construct(string $message[, int $lineno = -1 ][, Source|null $source = null ][, Throwable|null $previous = null ]) : mixed

By default, automatic guessing is enabled.

Parameters
$message : string

The error message

$lineno : int = -1

The template line where the error occurred

$source : Source|null = null

The source context where the error occurred

$previous : Throwable|null = null

appendMessage()

public appendMessage(mixed $rawMessage) : void
Parameters
$rawMessage : mixed

getRawMessage()

public getRawMessage() : string
Return values
string

getTemplateLine()

public getTemplateLine() : int
Return values
int

guess()

public guess() : void

setSourceContext()

public setSourceContext([Source|null $source = null ]) : void
Parameters
$source : Source|null = null

setTemplateLine()

public setTemplateLine(int $lineno) : void
Parameters
$lineno : int

guessTemplateInfo()

private guessTemplateInfo() : void

updateRepr()

private updateRepr() : void

        
On this page

Search results