A
A
AlexBoss2020-09-04 14:25:09
Python
AlexBoss, 2020-09-04 14:25:09

How to do custom Exceptions correctly?

Good afternoon. Can I somehow catch the exception through a custom error without explicitly raising it?
I want to do something like

class TestException(Exception):
   pass

try:
  ...
except TestException as e:
  print(e)


And so that for any Exception, the last block with TestException is processed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-09-04
@AlexBoss

No.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question