Quick search:


How to hande E_USER_WARNING and E_USER_ERROR

The phpPeanuts framework offers error handling and error logging. Since version 1.2 it is switched on by default. This is done in Site::setErrorHandler. The location of the error log file is set here too. In order to switch error handling on, remove the empty method 'setErrorHandler' in 'classSite.php' in the classes folder.

You may have to make the file 'pntErrorLog.txt' in the classes folder writable to the http server. If you use Linux as your web server you can do this with the chmod command (type chmod --help for help) and eventually chown. If you use web hosting from a provider, you can probably do it with your ftp client. If you use windows all your files may already be writable to everyone unless you have explicitly protected them.

The error handler should behave differently on your development server then on production servers: On the development server it should show a walkback in the normal user interface output that helps you find the cause of the error (walkback since 1.2). On production servers a page with a simple error message is shown. Therefore the error handler needs to know the hostname of your development server. It is important that you set it right, because otherwise you will be stuck with uninformative end user errors instead of informative development errors. Since 1.2 you can set it in Site::setErrorHandler. In older version you can edit 'classErrorHandler.php' in the 'classes' folder. To test the error handling type ?pntHandler=badname after the url that worked in your browser. On your development server You should get a raw php style error message, not a special error page. On all other servers your users will get the less informative but to end users less intimidating error page. Error logging is not affected by the development server setting: errors are always logged.

TIP: Since 1.2, when you are debugging you can output a backtrace even if there is no error by calling pntPrintBacktrace(debug_backtrace());