(self)
| 93 | self.translated = False |
| 94 | |
| 95 | def __str__(self): |
| 96 | # for translated errors we only return the message |
| 97 | if self.translated: |
| 98 | return self.message |
| 99 | |
| 100 | # otherwise attach some stuff |
| 101 | location = 'line %d' % self.lineno |
| 102 | name = self.filename or self.name |
| 103 | if name: |
| 104 | location = 'File "%s", %s' % (name, location) |
| 105 | lines = [self.message, ' ' + location] |
| 106 | |
| 107 | # if the source is set, add the line to the output |
| 108 | if self.source is not None: |
| 109 | try: |
| 110 | line = self.source.splitlines()[self.lineno - 1] |
| 111 | except IndexError: |
| 112 | line = None |
| 113 | if line: |
| 114 | lines.append(' ' + line.strip()) |
| 115 | |
| 116 | return u'\n'.join(lines) |
| 117 | |
| 118 | |
| 119 | class TemplateAssertionError(TemplateSyntaxError): |
nothing calls this directly
no test coverage detected