如何让 pycharm 中断我的异常
可能的重复:
pycharm 中未处理的异常中断
我是 Python 新手,我是尝试使用 PyCharm 1.5 调试我的第一个 python 程序。 我希望调试器在我的代码中发生异常时中断(并且仅在我的代码中)。
目前情况如下:我使用 (Ctrl + Shift + F8 ) 对话框来配置调试器,如果我设置 Suspend All = true 和 All excepts = true 则调试器会中断例如,它经常在 PyCharm 1.5.1\helpers\pydev\pydevd.py 内部的某个地方中断,每次都跳过这很烦人。如果我设置任何其他选项,那么即使代码中发生异常,调试器也不会中断。
PS:顺便说一句,如果我只是跳过 PyCharm 1.5.1\helpers\pydev\pydevd.py 中的中断,那么执行将继续,不会出现可见错误。所以我根本不明白为什么它会破裂
Possible Duplicate:
break on unhandled exception in pycharm
I'm new in Python and I'm trying to debug my first python program using PyCharm 1.5.
I want debugger to break when exception occurs in my code (and only in mine).
For now the situation is following: I use (Ctrl + Shift + F8 ) Dialog to configure debugger and If i set Suspend All = true and All exceptions = true then debugger breaks far too often, for example, it breaks somewhere inside PyCharm 1.5.1\helpers\pydev\pydevd.py which is annoying to skip every time. And if I set any other options then debugger does not break even when exception occurs in my code.
PS: By the way, if I just skip breaks in PyCharm 1.5.1\helpers\pydev\pydevd.py then execution continues without visible errors. So I do not understand why it breaks at all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
区分异常和来自库的异常的一种方法是让它们派生自自定义类,例如,如果您的模块称为 Foo,您可以拥有
并拥有从此派生的更具体的异常:
然后,在 PyCharm 中,改为要启用
All Exceptions
,请将FooException
添加到要中断的异常列表中。One way to tell apart your exceptions from exceptions coming from a library, is to have them derive from a custom class, e.g. if your module is called Foo, you could have
and have more specific exceptions derive from this:
Then, in PyCharm, instead of enabling
All Exceptions
, addFooException
to the list of exceptions to break upon.