Search code examples
mod-wsgierror-reporting

Display mod_wsgi error on webpage


I have set up mod_wsgi to serve python files. Indeed it does.

However, if i have syntax errors on the .py file (such as indentation errors), i get a Server Error when the page loads, and have to go to the log to see why the error occurred (ie, indentation)

Is it possible to have mod_wsgi display the error on the page (at least for dev environment)?

Something similar to php's error_reporting options, perhaps.


Solution

  • Not completely. The closest you can get is:

    http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Error_Catching_Middleware

    This will only do it for errors which occur during execution of a request which are actually propagated up to the WSGI server level.

    It will not work for errors in the loading of the WSGI sript itself, or in cases where a framework is being used and the framework itself catches the errors and turns then into 500 pages. In the latter, the framework usually has a means of enabling a debug page.

    Now, it sounds like you are not using a framework but are writing raw WSGI scripts. If you are new to Python web programming writing raw WSGI is not recommended. So, go use a framework instead and it should provide you what you want as a feature.