Hiding tracebacks from end-users

Alan Meyer ameyer2 at yahoo.com
Tue Oct 23 14:24:18 EDT 2007


On Oct 23, 12:07 pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:

...
>     if expert_mode:
>         # experts get the full traceback with no hand-holding.
>         raise
>     else:
>         # print a more friendly error message
...

Another approach is to always print a friendly error message,
but append the traceback to a log file (see the traceback
module for how to do that.)  The friendly error message can
include a note that full information is available in the log
file.

The advantage of that is that you capture critical information
that is otherwise lost when a non-expert user hits the exception.
For intermittent bugs that are hard to reproduce, this can be
a lifesaver - especially when your favorite non-expert user
seems to have a knack for generating errors that you can't figure
out how to create ;-)

    Alan




More information about the Python-list mailing list