I was practicing exception handling from sanfoundary and I got hanged up on a problem which had the problem statement like:
try:
if '1' != 1:
raise "someError"
else:
print("someError has not occurred")
except "someError":
print ("someError has occurred")
It is returning an error on running which I am unable to understand, i.e.,
Traceback (most recent call last):
File "M:\Prac\test2.py", line 3, in <module>
raise "someError"
TypeError: exceptions must derive from BaseException
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "M:\Prac\test2.py", line 6, in <module>
except "someError":
TypeError: catching classes that do not inherit from BaseException is not allowed