I've seen similar questions to this one but none of them really address the trackback.
If I have a class like so
def __init__(self, value one, operator, value_two, then, line_or_label, line_number):
self._firstvalue = value_one
self._secondvalue = value_two
self._operator = operator
self._gohere = line_or_label
self._then = then
self._line_number = line_number
def execute(self, OtherClass):
"code comparing the first two values and making changes etc"
`Syntax Error (Line 3): No -THEN- present in the statement.`
You can use a
try: and then
except Exception as inst:
What that will do is give you your error message in a variable named inst and you can print out the arguments on the error with
inst.args. Try printing it out and seeing what happens, and is any item in
inst.args is the one you are looking for.
EDIT Here is an example I tried with pythons IDLE:
>>> try: open("epik.sjj") except Exception as inst: d = inst >>> d FileNotFoundError(2, 'No such file or directory') >>> d.args (2, 'No such file or directory') >>> d.args 'No such file or directory' >>>
EDIT 2: as for closing the program you can always
raise and error or you can use