Re: [PHP-DEV] error reporting for PHP5

2002-11-25 Thread Ivan Ristic
Sorry to jump in the middle of a conversation, but I just wanted to
say that I personally use trigger_error() quite often.



  Me too, I use it for warnings, notices, and errors
  that cannot be remedied.

  In my programs I also simulate custom error codes. The first
  part of the error string looks something like

  [error.code] Message

  and I parse this later and act upon it.


The site I
maintain has a nice custom error handler which logs the error and
emails the admins the error details + var dumps, etc.


  Absolutely.


  I often use
trigger_error() in my code because it allows me to treat certain
situations the same as a PHP generated error.  Of course, I suppose I
could just call my custom error handler directly but that seems less
elegant...just MHO.



  The way with trigger_errors is better because you can at any
  time turn the custom error handler off, and everything would
  still work.


Bye,
Ivan



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




RE: [PHP-DEV] error reporting for PHP5

2002-11-24 Thread John Coggeshall

I've been cut off from my e-mail since Thursday, so I'm going to have to
play catch-up a little here... 

Issue #1: Maxim's Error handling suggestions

I completely agree with the concept of language-specific errors. I'll be
happy to implement a system on that. However before we do that I think
what should be changed and why needs to be explored a little more... 

I am pretty much in favor for most of what Maxim is suggesting on this,
however one thing that I wasn't sure is being suggested is splitting the
constants into two three groups -- type, module, error. Where E_NOTICE,
E_ERROR, etc. would be the type of error, MOD_CURL, MOD_FOOBAR would be
the module in which the error occurred and E_CURL_BADURL would be the
actual error code.

As for custom error codes, I'm not sure how these would be handled in
PHP... In fact, I'm not entirely convince that we really should have
this sort of thing (i.e. trigger_error()). In my experience (and maybe
I'm unique) I have never actually used trigger_error() in any sort of
meaniful way. Rather, I simply deal with the error myself. I am open to
hearing everyone's ideas on what could be done in this respect.. The
best thought I would have is similar to Maxim's, where you could
register your own module constant (see above) and error codes... Then
PHP could just look them up in the XML document. Perhaps if this system
was available (along with my patch) I'd be using them much more
frequently. 

As for actual implementation, there would need to be a couple new
directives:

error_dir   The directory containing the XMLs
default_error_lang  The language default for errors (perhaps we
could use an already existing language directive?)

And a few functions added/mod'd:

Trigger_error($mod, $error) -- trigger an error  with code $error in mod
$mod (the type of error, E_ERROR, etc, is taken from the XML)
Register_error($type, $mod, $error, $msg [, $lang]) -- register an error
at runtime of type $type for module $mod, errorcode $error with the
message $msg. An option parameter $lang specifies the language the error
is in
Include_errordef($file) -- Include an error defination XML file at
run-time
Set_error_language($lang) -- Set a new error-language (perhaps this
would be better to just be set_language() for all of PHP?)

Of course callback custom error handlers would have to be changed to
accept only $mod, and $error

Notice I left Maxim's suggestion of modify_error() out... The reason is
because there should be no reason to modify the error message at
runtime... If you want to specifically define an error  to distinguish
between an undefined username and an undefined variable

Register_error(E_ERROR, USER_MYSCRIPT, E_MYSCRIPT_UNDEF);
If(!isset($username)) 
trigger_error(USER_MYSCRIPT, E_MYSCRIPT_UNDEF);


Issue #2: The 500 error...

I'm -1 on this. The reason I'm -1 is because no one has shown me a
reason why the 500 error is a more reasonable solution than the Patch
I've already written which accomplishes the same thing. In fact, it does
a better job because the error page knows exactly what went wrong
(unlike a 500 error, which just means something went wrong). 

Issue #3: The redirect patch

Although there are a few things to do for the patch before I commit
(make it more friendly when other error handlers are used,  use the
argument_seperator from the INI, etc) it is basically ready and working.
If no one has any serious objections I'll clean up the code and commit
it when I've tested it. Also, this works out fairly well because the
patch can be easily modified to work with the new system Maxim
discussed. 

My 2c -- sorry for being long winded (had to catch up).

John


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




Re: [PHP-DEV] error reporting for PHP5

2002-11-24 Thread Michael Sims
On Mon, 25 Nov 2002 01:04:00 -0500, you wrote:

As for custom error codes, I'm not sure how these would be handled in
PHP... In fact, I'm not entirely convince that we really should have
this sort of thing (i.e. trigger_error()). In my experience (and maybe
I'm unique) I have never actually used trigger_error() in any sort of
meaniful way. Rather, I simply deal with the error myself.

Sorry to jump in the middle of a conversation, but I just wanted to
say that I personally use trigger_error() quite often.  The site I
maintain has a nice custom error handler which logs the error and
emails the admins the error details + var dumps, etc.  I often use
trigger_error() in my code because it allows me to treat certain
situations the same as a PHP generated error.  Of course, I suppose I
could just call my custom error handler directly but that seems less
elegant...just MHO.

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




Re: [PHP-DEV] error reporting for PHP5

2002-11-21 Thread Chris Shiflett
I quite like Maxim's ideas myself.

+1

--- Maxim Maletsky [EMAIL PROTECTED] wrote:

 I will start laying out some my thoughts to hopefully get a
 discussion towards working on the complete error reporting logic.
 I had an extensive experience implementing custom errors, so
 approve or disapprove my ideas.

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