Wik\Lexer\Exceptions\LexException, which itself extends \RuntimeException. You can catch any Lex exception by catching LexException, or catch individual types for more precise error handling.
In development mode, the Chrome DevTools error overlay intercepts
TemplateSyntaxException and displays the file, line, column, and source snippet with an Open in VS Code button. See the DevTools extension guide for setup instructions.Exception reference
TemplateSyntaxException
TemplateSyntaxException
Full class name:
When it is thrown
Wik\Lexer\Exceptions\TemplateSyntaxExceptionThrown when a template contains a syntax or structural error detected at compile time — during lexing, parsing, or AST validation.Data it carries| Property | Type | Description |
|---|---|---|
$templateFile | string | Absolute path to the template file |
$templateLine | int | Line number where the error occurred |
$templateColumn | int | Column number where the error occurred |
$snippet | string | Formatted source snippet (±2 lines around the error) |
- Parse or compile errors with a precise source location
- Unclosed blocks (e.g.
#ifwith no#endif) - Mismatched component closing tags
- Duplicate
#sectiondefinitions - Sandbox violations (forbidden expression or function)
- Invalid PHP expressions in
{{ }}or{!! !!}
TemplateRuntimeException
TemplateRuntimeException
Full class name:
When it is thrown
Wik\Lexer\Exceptions\TemplateRuntimeExceptionThrown when an error occurs while executing a compiled template — that is, after compilation has succeeded and the compiled PHP is actually running.Data it carries| Property | Type | Description |
|---|---|---|
$templateFile | string | Path to the template that triggered the error |
$templateLine | int | Line number in the source template (when available) |
- An infinite layout loop is detected (a layout template renders itself)
- Component recursion exceeds the configured limit
{!! ... !!}raw echo is used in sandbox mode withrawEchodisabled- A PHP error occurs inside a compiled template at runtime
ViewException
ViewException
Full class name:
Wik\Lexer\Exceptions\ViewExceptionThrown when the view engine cannot locate a template or component file, or when no view paths or cache directory have been configured.Data it carriesInherits the standard RuntimeException $message. No additional properties.When it is thrown- A template name cannot be resolved to a
.lexfile in any configured view path - A component tag cannot be resolved to a
.lexfile in anycomponents/subdirectory - No cache directory has been configured before rendering
- No view paths have been configured before rendering
LexerException
LexerException
Full class name:
Wik\Lexer\Exceptions\LexerExceptionThrown by the tokenizer when it encounters an unterminated expression or tag during the lexing pass.Data it carriesInherits the standard RuntimeException $message. The line number where the unterminated expression started is included in the message.When it is thrown- An echo expression
{{ ... }}is opened but never closed - A raw echo expression
{!! ... !!}is opened but never closed - A component opening tag
<ComponentNameis not terminated
ParseException
ParseException
Full class name:
Wik\Lexer\Exceptions\ParseExceptionThrown by the parser when it encounters structural problems in the token stream — such as mismatched blocks or directives it does not recognise.Data it carriesInherits the standard RuntimeException $message. The relevant line number is embedded in the message.When it is thrown- A closing directive appears with no matching opening block (e.g.
#endifwith no#if) - A closing component tag has no matching opening tag
- A component opening tag and its closing tag have different names
- A block is still open when a parent block is closed (nested block must close first)
- An unknown directive name is encountered and has not been registered via
$lexer->directive()
CompilerException
CompilerException
Full class name:
Wik\Lexer\Exceptions\CompilerExceptionThrown when the compiler cannot write to the cache directory or cannot complete compilation of a template.Data it carriesInherits the standard RuntimeException $message. No additional properties.When it is thrown- The cache directory does not exist and cannot be created, or is not writable
- Compilation of a specific template fails (message includes the template name and reason)