0

I'm trying to define a bunch of custom exceptions in Python for my code, and my first idea has been to create a file called exceptions.py where I've defined several custom Exceptions. You can see what I've done in the image.

enter image description here

However, as you can see, only the first class is correctly highlighted. Also, when I import this exception, it always raises, no matter if I call it or not. What am I doing wrong? What's the best practice in this case?

Thank you so much for the support.

ignacioct
  • 325
  • 1
  • 12
  • Why do you have `print()` and `exit()` in your classes? – quamrana Oct 10 '22 at 07:40
  • 2
    Please include your code as text and not as an image. – ewokx Oct 10 '22 at 07:42
  • 2
    Just write `class SharepyAuthError(Exception): pass`, with the docstring. In your given code, simply defining the class calls `exit()` to exit Python. – Jerry101 Oct 10 '22 at 07:42
  • 1
    You may find this discussion helpful:- https://stackoverflow.com/questions/1319615/proper-way-to-declare-custom-exceptions-in-modern-python – DarkKnight Oct 10 '22 at 07:43

0 Answers0