Raised for template syntax errors. ``ParseError`` instances have ``filename`` and ``lineno`` attributes indicating the position of the error. .. versionchanged:: 4.3 Added ``filename`` and ``lineno`` attributes.
| 698 | |
| 699 | |
| 700 | class ParseError(Exception): |
| 701 | """Raised for template syntax errors. |
| 702 | |
| 703 | ``ParseError`` instances have ``filename`` and ``lineno`` attributes |
| 704 | indicating the position of the error. |
| 705 | |
| 706 | .. versionchanged:: 4.3 |
| 707 | Added ``filename`` and ``lineno`` attributes. |
| 708 | """ |
| 709 | |
| 710 | def __init__( |
| 711 | self, message: str, filename: Optional[str] = None, lineno: int = 0 |
| 712 | ) -> None: |
| 713 | self.message = message |
| 714 | # The names "filename" and "lineno" are chosen for consistency |
| 715 | # with python SyntaxError. |
| 716 | self.filename = filename |
| 717 | self.lineno = lineno |
| 718 | |
| 719 | def __str__(self) -> str: |
| 720 | return "%s at %s:%d" % (self.message, self.filename, self.lineno) |
| 721 | |
| 722 | |
| 723 | class _CodeWriter(object): |
no outgoing calls