\Twig_Error
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 filename is set to null). As this is a costly operation, this
can be disabled by passing false for both the filename and the line number
when creating a new instance of this class.
- Author: Fabien Potencier <fabien@symfony.com>
Synopsis
- // members
- protected $lineno;
- protected $filename;
- protected $rawMessage;
- protected $previous;
- // Inherited members from Exception
- protected $message;
- protected $code;
- protected $file;
- protected $line;
- // methods
- public void __construct()
- public string getRawMessage()
- public string getTemplateFile()
- public void setTemplateFile()
- public integer getTemplateLine()
- public void setTemplateLine()
- public void guess()
- public Exception __call()
- protected void updateRepr()
- protected void guessTemplateInfo()
- // Inherited methods from Exception
- public void __construct()
- public final string getMessage()
- public final Exception getPrevious()
- public final mixed getCode()
- public final string getFile()
- public final int getLine()
- public final array getTrace()
- public final string getTraceAsString()
- public string __toString()
Hierarchy
Extends
Extended by
Members
protected
- $code
—
int
The exception code - $file
—
string
The filename where the exception was created - $filename
- $line
—
int
The line where the exception was created - $lineno
- $message
—
string
The exception message - $previous
- $rawMessage
Methods
protected
public
- __construct() — Constructor.
- __call() — For PHP < 5.3.0, provides access to the getPrevious() method.
- getRawMessage() — Gets the raw message.
- getTemplateFile() — Gets the filename where the error occurred.
- getTemplateLine() — Gets the template line where the error occurred.
- guess()
- setTemplateFile() — Sets the filename where the error occurred.
- setTemplateLine() — Sets the template line where the error occurred.
Inherited from Exception
public
- __toString() — String representation of the exception
- getCode() — Gets the Exception code
- getFile() — Gets the file in which the exception occurred
- getLine() — Gets the line in which the exception occurred
- getMessage() — Gets the Exception message
- getPrevious() — Returns previous Exception
- getTrace() — Gets the stack trace
- getTraceAsString() — Gets the stack trace as a string