1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.