I'm on Windows and using python 3.7.7. I am trying to make a golfing language. In that e. if you raise an Exception (to be clear NameError) like this:
raise NameError("Your input was not recognized as a function, variable or datatype")
Then the program automatically quits. When I tried this:
print(NameError("Your input was not recognized as a function, variable or datatype"))
Then it prints the error but not fully and not in red like this:
Your input was not recognized as a function, variable or datatype
Is there a way that the program should not quit and print a real error?
I'm surprised no one has mentioned the Python termcolor module. Usage is pretty simple:
Python 2:
Or in Python 3:
Along with the use of "try-except" statement, since after all, you can raise exceptions without quitting the program, by adding something in the except clause.