Skip to content

Commit

Permalink
clearer errors for undefined variables and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
gboehl committed Dec 9, 2023
1 parent fb37de9 commit 02721eb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pydsge/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def parse(cls, mtxt, ffile):
rhs = eval(rhs, context)
except TypeError as e:
raise SyntaxError(
"While parsing %s, got this error: %s" % (
"While parsing the equation\n\n %s\n\nI got the error %s. This usually happens because a variable is not declared or a parameter is not defined. Note: undefined parameters may not necessarily be associated with the above equation." % (
raw_const, repr(e))
)

Expand Down Expand Up @@ -665,7 +665,8 @@ def parse(cls, mtxt, ffile):
rhs = sympy.sympify(rhs)
except TypeError as e:
raise SyntaxError(
"While parsing %s, got this error: %s" % (eq, repr(e))
"While parsing the equation\n\n %s\n\nI got the error %s. This usually happens because a variable is not declared or a parameter is not defined. Note: undefined parameters may not necessarily be associated with the above equation." % (
eq, repr(e))
)

equations.append(Equation(lhs, rhs))
Expand Down

0 comments on commit 02721eb

Please sign in to comment.