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 (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Tags
Table of Contents
- $lineno : mixed
- $name : mixed
- $rawMessage : mixed
- $sourceCode : mixed
- $sourcePath : mixed
- __construct() : mixed
- Constructor.
- appendMessage() : mixed
- getRawMessage() : string
- Gets the raw message.
- getSourceContext() : Source|null
- Gets the source context of the Twig template where the error occurred.
- getTemplateLine() : int
- Gets the template line where the error occurred.
- guess() : mixed
- setSourceContext() : mixed
- Sets the source context of the Twig template where the error occurred.
- setTemplateLine() : mixed
- Sets the template line where the error occurred.
- guessTemplateInfo() : mixed
- updateRepr() : mixed
Properties
$lineno
private
mixed
$lineno
$name
private
mixed
$name
$rawMessage
private
mixed
$rawMessage
$sourceCode
private
mixed
$sourceCode
$sourcePath
private
mixed
$sourcePath
Methods
__construct()
Constructor.
public
__construct(string $message[, int $lineno = -1 ][, Source|string|null $source = null ][, Exception $previous = null ]) : mixed
Set the line number to -1 to enable its automatic guessing. Set the name to null to enable its automatic guessing.
Parameters
- $message : string
-
The error message
- $lineno : int = -1
-
The template line where the error occurred
- $source : Source|string|null = null
-
The source context where the error occurred
- $previous : Exception = null
-
The previous exception
Return values
mixed —appendMessage()
public
appendMessage(mixed $rawMessage) : mixed
Parameters
- $rawMessage : mixed
Return values
mixed —getRawMessage()
Gets the raw message.
public
getRawMessage() : string
Return values
string —The raw message
getSourceContext()
Gets the source context of the Twig template where the error occurred.
public
getSourceContext() : Source|null
Return values
Source|null —getTemplateLine()
Gets the template line where the error occurred.
public
getTemplateLine() : int
Return values
int —The template line
guess()
public
guess() : mixed
Return values
mixed —setSourceContext()
Sets the source context of the Twig template where the error occurred.
public
setSourceContext([Source $source = null ]) : mixed
Parameters
- $source : Source = null
Return values
mixed —setTemplateLine()
Sets the template line where the error occurred.
public
setTemplateLine(int $lineno) : mixed
Parameters
- $lineno : int
-
The template line
Return values
mixed —guessTemplateInfo()
private
guessTemplateInfo() : mixed
Return values
mixed —updateRepr()
private
updateRepr() : mixed