> I think in a modern web application the error handling function should do
> the following:
> in case of error (any: parse error, internal application error,....)
> 
> 1. a message should be shown to the user sayng that an error has occured
> like "an internal error has occured. the webmaster has been notified via
> email"
> 2. a more detailed message should be logged in a generic system ErrorLog, or
> notified via email or fax, or telephone, or SMS. Depending on the severity
> of the error (warning, fatal,...)

On a similar note, I posted a patch a few days ago which was intended
for development environments - it makes error messages appear in a
clear 'window' in the middle of the browser window, so that you don't
have to hunt around in the output of the program to find it.  I've
attached it again, in case you're insterested.

John.
Index: main/main.c
===================================================================
RCS file: /repository/php4/main/main.c,v
retrieving revision 1.512
diff -u -r1.512 main.c
--- main/main.c 12 Nov 2002 14:40:00 -0000      1.512
+++ main/main.c 14 Nov 2002 20:57:31 -0000
@@ -246,6 +246,7 @@
        STD_PHP_INI_BOOLEAN("expose_php",                       "1",            
PHP_INI_SYSTEM,         OnUpdateBool,                   expose_php,                    
         php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("docref_root", "http://www.php.net/";, PHP_INI_ALL,           
 OnUpdateString,                 docref_root,                    php_core_globals,     
  core_globals)
        STD_PHP_INI_ENTRY("docref_ext",                         "",                    
 PHP_INI_ALL,            OnUpdateString,                 docref_ext,                   
          php_core_globals,       core_globals)
+       STD_PHP_INI_BOOLEAN("fancy_html_errors",        "1",            PHP_INI_ALL,   
+         OnUpdateBool,                   fancy_html_errors,              
+php_core_globals,       core_globals)
        STD_PHP_INI_BOOLEAN("html_errors",                      "1",            
PHP_INI_ALL,            OnUpdateBool,                   html_errors,                   
 php_core_globals,       core_globals)
        STD_PHP_INI_BOOLEAN("xmlrpc_errors",            "0",            
PHP_INI_SYSTEM,         OnUpdateBool,                   xmlrpc_errors,                 
 php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("xmlrpc_error_number",        "0",            PHP_INI_ALL,   
         OnUpdateInt,                    xmlrpc_error_number,    php_core_globals,     
  core_globals)
@@ -453,7 +454,11 @@
                                }
                        }
                        if (PG(html_errors)) {
-                               php_error(type, "%s(%s) [<a href='%s%s%s'>%s</a>]: 
%s", get_active_function_name(TSRMLS_C), params, docref_root, docref, docref_target, 
docref, buffer);
+                               if (PG(fancy_html_errors)) {
+                                       php_error(type, "<div 
+style=\"position:fixed;left:25%;right:25%;top:25%;bottom:25%;border-style:dashed;border-size:2;background:white;\">%s(%s)
+ [<a href='%s%s%s'>%s</a>]: %s</div>", get_active_function_name(TSRMLS_C), params, 
+docref_root, docref, docref_target, docref, buffer);
+                               } else {
+                       }       
+                       php_error(type, "%s(%s) [<a href='%s%s%s'>%s</a>]: %s", 
+get_active_function_name(TSRMLS_C), params, docref_root, docref, docref_target, 
+docref, buffer);
                        } else {
                                php_error(type, "%s(%s) [%s%s%s]: %s", 
get_active_function_name(TSRMLS_C), params, docref_root, docref, docref_target, 
buffer);
                        }
@@ -609,6 +614,9 @@
                        error_format = PG(html_errors) ?
                                "<br />\n<b>%s</b>:  %s in <b>%s</b> on line 
<b>%d</b><br />\n"
                                : "\n%s: %s in %s on line %d\n";
+                       if (PG(fancy_html_errors)) {
+                       error_format = "<div 
+style=\"position:fixed;left:25%;right:25%;top:25%;bottom:25%;border-style:dashed;border-size:2;background:white;\"><br
+ />\n<b>%s</b>:  %s in <b>%s</b> on line <b>%d</b><br /></div>\n";
+                       }
                        if (PG(xmlrpc_errors)) {
                                error_format = do_alloca(ERROR_BUF_LEN);
                                snprintf(error_format, ERROR_BUF_LEN-1, "<?xml 
version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%ld</int></value></member><member><name>faultString</name><value><string>%%s:%%s
 in %%s on line 
%%d</string></value></member></struct></value></fault></methodResponse>", 
PG(xmlrpc_error_number));
Index: main/php_globals.h
===================================================================
RCS file: /repository/php4/main/php_globals.h,v
retrieving revision 1.84
diff -u -r1.84 php_globals.h
--- main/php_globals.h  21 Oct 2002 16:41:06 -0000      1.84
+++ main/php_globals.h  14 Nov 2002 20:57:31 -0000
@@ -125,6 +125,7 @@
        char *docref_ext;
 
        zend_bool html_errors;
+       zend_bool fancy_html_errors;
        zend_bool xmlrpc_errors;
 
        long xmlrpc_error_number;

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to