How to make program stop only when exceptions are raised? #1796
Unanswered
natsu1375
asked this question in
Enhancements
Replies: 1 comment
-
Sorry but what you're asking for isn't currently possible. A debugger must be attached in order to stop on exceptions. There's no way to launch a debugger after the program has already thrown the exception. Theoretically the idea is possible though. You wouldn't use debugpy though, but something smaller that just listened to exception events and then possibly stopped the program and called out to VS code to attach. I'll transfer this to a discussion item. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If run debugpy with
--wait-for-client
, the program stops and wait for connection. After client's connection, breakpoint() makes program stop, and also raised exceptions ifRaised Exceptions
is checked in VSCode.But in my use cases, I don't want to use
--wait-for-client
as it stops the whole thing. I just want to debug the program if something goes wrong, such as assertions failed. If nothing goes wrong, the program proceeds normally to the end.For example, this program
Run it with
python -m debugpy --listen 1234 foo.py
. The program did not stop atassert x==0
, but this uncaught exception make it exit.Beta Was this translation helpful? Give feedback.
All reactions