diff --git a/parsimonious/exceptions.py b/parsimonious/exceptions.py index a03a549..b9e05bc 100644 --- a/parsimonious/exceptions.py +++ b/parsimonious/exceptions.py @@ -3,7 +3,12 @@ from parsimonious.utils import StrAndRepr -class ParseError(StrAndRepr, Exception): +class ParsimoniousError(Exception): + """A base exception class to allow library users to catch any Parsimonious error.""" + pass + + +class ParseError(StrAndRepr, ParsimoniousError): """A call to ``Expression.parse()`` or ``match()`` didn't match.""" def __init__(self, text, pos=-1, expr=None): @@ -71,7 +76,7 @@ def __str__(self): self.column()) -class VisitationError(Exception): +class VisitationError(ParsimoniousError): """Something went wrong while traversing a parse tree. This exception exists to augment an underlying exception with information @@ -100,7 +105,7 @@ def __init__(self, exc, exc_class, node): node.prettily(error=node))) -class BadGrammar(StrAndRepr, Exception): +class BadGrammar(StrAndRepr, ParsimoniousError): """Something was wrong with the definition of a grammar. Note that a ParseError might be raised instead if the error is in the