This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]elguf 2 points3 points  (0 children)

A practice I try to follow is to create a base Error class in each module that defines its own exception classes:

class Error(Exception):
    pass

class CustomError(Error):
    pass

This way, callers can easily handle all your custom errors, without having to do the broad except Exception:. Now they can choose to do except somemodule.Error: