Raise error on python exception. The following code shows how to raise an error on python exception.
try:
raise NameError('Hey! It is a custom error message.')
except NameError as e:
print(e)
Output:
Hey! It is a custom error message.