Moin 1.3 has a new user friendly error messages, that show up when you make a configuration mistake or known internal error happens. The problem with these nice errors is that they hide the real exceptions, making debugging harder.

In general we should not have fatal errors. We should recover from most errors in a sane way, with a friendly error message in the page itself, for example, like too long file names is treated. But sometimes we have errors that we can't recover from - like configuration errors. In these cases, FatalError sub classes are useful.

Different types of users

Users, wiki administrators and developers need different error messages:

Developers

Wiki admin

Users

Default error report

Debug mode error message

How to set debug mode

Moin uses environment variables or query:

Use the query to debug quickly, and the environment variable when developing.

Planning

Improve logging

currently we print the error message to the log, without the traceback.

Save html traceback to a log dir

cgitb has already support for logdir. We can easily add this feature:

Each traceback will save in the logdir directory if you define MOIN_DEBUG_LOGDIR. Each traceback is saved as tmpxxxxxx.html.

os.environ['MOIN_DEBUG_LOGDIR'] = '/path/to/logdir'

Those random names suck - names like traceback--yyyy-mm-dd--hh-mm-ss--nn.html is much better. I think it can be a useful feature for any user of cgitb.

This can be useful to read detailed tracebacks in a browser without showing sensitive information to the world.

Traceback log

Have a special log for tracebacks, containing full tracebacks in text format.

Before we load the config, we can't access the wiki error log, so this should go to separate log. For example, <server script>.log in the same directory as the server script

After we loaded the config, we can print the tracebacks to the wiki error.log.

Privacy issues

Don't show sensitive information:

Problem: some data is needed for debugging. If we filter sensitive data in tracebacks, we might get bug reports with missing information.

Alternatives:

Filtering data in traceback

We can add a filter fuction to cgitb.Frame that filter values of certain names.

Problems:

I don't think it will work, be very fragile and make debugging harder.

Don't display tracebacks for non local requests

In very early stage, it may be hard to tell if this is a local request.

We can use this feature anyway, together with debug levels.

Use debug levels

To implement this, we have to add 2 lines of code, check debug level, and create cgitb.Hook with the proper display and logdir values.

I think that this is the way to go.

2.0

MoinMoin: UsefulErrors (last edited 2007-10-29 19:12:13 by localhost)