Python - Raise an exception with message
In order to raise an exception in python you need to use raise keyword followed by type of exception. For example if you want to raise file not found exception with a message that given file doesn’t exists, you can use below syntax:
raise FileNotFoudError(“Given file doesn’t exist”)
If you want to raise a type error exception you can use:
raise TypeError(“Given input is of not s valid type”)