Skip to content

Commit 325aeaa

Browse files
jdufresnegsnedders
authored andcommitted
Add useful message to the ParseError exception.
Sometimes, I would like to be able to catch ParseError, and output its message immediately. Set the exception's message to the parser error message.
1 parent f644865 commit 325aeaa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

html5lib/html5parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .constants import tokenTypes, ReparseException, namespaces
1919
from .constants import htmlIntegrationPointElements, mathmlTextIntegrationPointElements
2020
from .constants import adjustForeignAttributes as adjustForeignAttributesMap
21+
from .constants import E
2122

2223

2324
def parse(doc, treebuilder="etree", encoding=None,
@@ -256,7 +257,7 @@ def parseError(self, errorcode="XXX-undefined-error", datavars={}):
256257
# XXX The idea is to make errorcode mandatory.
257258
self.errors.append((self.tokenizer.stream.position(), errorcode, datavars))
258259
if self.strict:
259-
raise ParseError
260+
raise ParseError(E[errorcode] % datavars)
260261

261262
def normalizeToken(self, token):
262263
""" HTML5 specific normalizations to the token stream """

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy