I want to declare a custom exception class such that whenever it is raised it will do a specific set of actions. I would be raising this exception at multiple places so don't want to add an except block at all these places. Instead I prefer to override the function which would raise the error.
Suppose I have a class -
class CustomException(Exception):
pass
I do this -
raise CustomException(**kwargs)
I wish to extract data from the kwargs and do some action depending on them.