Best Way to Handle All Exceptions

Piet van Oostrum piet at cs.uu.nl
Tue Jul 14 16:45:46 EDT 2009


>>>>> Carl Banks <pavlovevidence at gmail.com> (CB) wrote:

>CB> On Jul 14, 4:48 am, Lawrence D'Oliveiro <l... at geek-
>central.gen.new_zealand> wrote:
>>> In message <93f6a517-63d8-4c80-
>>> 
>>> bf19-4614b7099... at m7g2000prd.googlegroups.com>, Carl Banks wrote:
>>> > Or would you rather let all unexpected exceptions print to standard
>>> > error, which is often a black hole in non-interactive sitations?
>>> 
>>> Since when?
>>> 
>>> Cron, for example, collects standard error and mails it to you.

>CB> 1. Cron is only one way to run programs non-interactively. (Would that
>CB> work with, say, Windows services?)
>CB> 2. Many systems don't run MTAs these days
>CB> 3. In my experience the pipeline from cron to mail delivery is error
>CB> prone, mainly due to the complexity of configuring MTAs
>CB> 4. Even if all this works, you might just want to do your logging
>CB> directly in Python anyway

Even then, I think the program would get structured better if the FTP
code would only catch FTP-specific errors, including socket errors
(which is what all_errors does) and to catch programming errors etc on
another level, e.g by the mentioned sys.excepthook.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list