python usually defines user-defined exceptions, so they can return a specific user test / output / regardless of when the error occurred in a user-defined class. But I wonder if there is good practice for handling exceptions for a given class in python? In detail, I have the following questions:
Should all class-related exceptions be in the file that the python class defines, or should they go to a specific file?
Should exceptions be defined for any conceivable case of things that should throw an exception, or is it βnormalβ to simply define a general exception for the class and print out information about where and what happened in the wrong way by providing some additional text?
I would appreciate it if someone could post an example of how a custom exception might / should look like, therefore, to understand why it's nice to define your own specific exception class.
Thanks Alex
source share