+ 2
How can I raise user-defined exceptions in python?
Hello, I have the following code, which consists of a class "Errors" which is meant to have classmethods with user-defined errors. The code snippet was taken out of a program, however it doesn't rely on the rest of the code. When I call a class method, which raises a certain error, at the end I get "NameError" - which means that the error from a classmethod I have called does not exist - this is true indeed. I want to be able to call user-defined exceptions without a "NameError" pop up at the end. How can I do so? And do I need to inherit Exceptions class into my own class? https://code.sololearn.com/cLUvW71Xx2Gv/?ref=app
4 Respuestas
+ 5
I hope it will help you
https://www.scaler.com/topics/user-defined-exception-in-JUMP_LINK__&&__python__&&__JUMP_LINK/
+ 3
That's exactly what I wanted:
https://code.sololearn.com/cZvpksGD7zyO/?ref=app
Used classmethods in here, but someone said to store user defined errors in a package rather than a class
+ 2
I was on here, it's not exactly what I want , thanks for answering though
+ 1
Jay Matthews thanks. now I see what I need to do, although syntax is a bit scary 😅