Classes
ErrorHandlingMixin
1
▼
Mixin for compiling error boundary statements.
Host attributes and cross-mixin dependencies are de…
ErrorHandlingMixin
1
▼
Mixin for compiling error boundary statements.
Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks.
Methods
Internal Methods 1 ▼
_compile_try
1
list[ast.stmt]
▼
Compile {% try %}...{% fallback %}...{% end %} error boundary.
Both StringBuil…
_compile_try
1
list[ast.stmt]
▼
def _compile_try(self, node: Try) -> list[ast.stmt]
Compile {% try %}...{% fallback %}...{% end %} error boundary.
Both StringBuilder and streaming modes use the same sub-buffer strategy for the try body (must buffer to discard on error).
Generated code (StringBuilder mode):
_try_buf_N = []
_try_append_N = _try_buf_N.append
_saved_append_N = _append
_append = _try_append_N
try:
# body compiled with _append → sub-buffer
_append = _saved_append_N
_append(''.join(_try_buf_N))
except (...) as _err_N:
_append = _saved_append_N
# fallback body
Generated code (streaming mode):
_try_buf_N = []
_append = _try_buf_N.append
try:
# body compiled in non-streaming mode → _append to buffer
for _chunk in _try_buf_N: yield _chunk
except (...) as _err_N:
# fallback body compiled in streaming mode (yields)
Parameters
| Name | Type | Description |
|---|---|---|
node |
— |
Returns
list[ast.stmt]