Raise error on python exception

Raise error on python exception

Instructor-svg Al-Mamun Sarkar
Mar 25 , 2020

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.

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram