[Sugar-devel] Ignoring certain exceptions while debugging...?

Tomeu Vizoso tomeu at sugarlabs.org
Tue Feb 17 06:39:54 EST 2009


On Tue, Feb 17, 2009 at 12:26, Martin Langhoff
<martin.langhoff at gmail.com> wrote:
> On Tue, Feb 17, 2009 at 10:48 PM, Tomeu Vizoso <tomeu at sugarlabs.org> wrote:
>>> Is there a better way?
>>
>> Sorry about the late reply. I'm having trouble understanding the
>> doubt, can you reformulate your question (if it's still valid)?
>
> Use case: I write my code, adding nice exceptions to handle all the
> things that could go wrong. In particular, I want some errors to be
> pretty much ignored.

But you want them still logged as errors?

I would say for always logging any exceptions that are thrown except
in corner cases where you can check before trying if that operation
will fail.

You can print the stack trace from the handler with traceback.format_exc()

> When I start to test and I hit those error conditions. Except that...
> as I am developing, I want to say "no no, for now, don't hide them
> from me" so I can judge the errors: some may be in my code.
>
> Anyway, right after I wrote that email I walked into a
> Python-Users-Group thing happening at my office. One of them suggested
> that I add a bare 'raise' at the end of the exception handling.
> Looking at the docs, his recommendation makes sense -- haven't tried
> it.

That will reraise the exception that is being handled, useful when you
want to cleanup something, but then let the exception keep flowing as
usual.

Regards,

Tomeu

> cheers,
>
>
> m
> --
>  martin.langhoff at gmail.com
>  martin at laptop.org -- School Server Architect
>  - ask interesting questions
>  - don't get distracted with shiny stuff  - working code first
>  - http://wiki.laptop.org/go/User:Martinlanghoff
>


More information about the Sugar-devel mailing list