John, Steve, Thanks for your comments.
John: Thanks for cluing me in to the exception mode setting. I'd been looking for it in the project settings, and instead it's in the IDE settings.
But, as I expected (and you note) turning on Always results in a large number of exception stops from startup code and included libraries even before my own code is reached. So not terribly usable.
So I guess I would like to know what the prospects are for an option that acts like "Always", but only for selected code regions -- for example "all modules open in the IDE", or "modules that are flagged" or somesuch.
Steve: Yes, one should use exceptions well :-). But there's a bit of a tradeoff between cluttering the code with super-precise excepts (not to mention figuring out what they are) so as to avoid catching unanticipated exceptions, versus including the excepts to catch the unanticipated exceptions so that the deployed code can fail a bit more gracefully.
For example, in a function that's supposed to open a file and load its data into a structure, I just want to wrap that whole thing in a try-except block that catches any reason for failure, combines some context info with the exception message, and passes that back to the caller. I don't really want to figure out all possible "legitimate" failure reasons. And I don't want it to bubble up an exception for the illegitimate reasons, just so I can get the IDE to stop on unhandled exceptions during debugging.
At least, that's been my thinking.
You prompted me to investigate the Exception.__traceback__ object, and that does indeed allow more precise (if end-user-baffling) error reports. But I can centralize the incorporation of the traceback info in one place, and easily disable that for deployment.
That said, I've not seen a way to get the nice precise error message ("FileXYZ, Line 123") in the Debug I/O window to tell the IDE to actually go to that location.
:-)
-- Graham
At 2/25/2014 06:59 AM, Wing IDE Support wrote:
>On 2/24/14, 7:37 PM, Graham Wideman wrote:
>>Is there a setting, feature or approach to get WingIDE debugger to stop on exceptions, even within try..except blocks? (A feature I'm used to having in IDEs for other languages.)
>>Unfortunately, exceptions are used too frequently in Python for stopping on any exception to be all that useful. There is an exception mode that does this that can be set in the Debugger -> Exceptions preferences -- it's the Always option for the Report Exceptions setting -- but it stops too often, at least for me.
>>Cheers,
>>John