RE: [PHP-DOC] Re: error handling [was: ugly cvs subject]
| From: | John Coggeshall | Date: | Mon, 02 Dec 2002 18:50:53 +0000 |
| Subject: | RE: [PHP-DOC] Re: error handling [was: ugly cvs subject] | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969350116@lists.php.net to get a copy of this message | ||
>Of course, this does introduce the problem of scripters
>leaving the verbose error messages in their code when they're
>ready for production.
IMHO I guess I'm still of the opinion that the PHPDocs aren't really a
resource for "Good practices", there are plenty of other resources
available online for that. I think the PHPDoc should focus on straight
facts... If we want to use trigger_error() instead of die() that's
fine... But if you're a newbie the difference between "development" and
"production" web sites don't exist.... I guess I just feel like if you
know the difference then you inheritly know that certain development
error messages shouldn't be displayed. Hence, I'm -1 on the idea that we
should clutter the manual with such attempts.
>Should set_error_handler()'s documentation be updated at the
>same time to reflect switching between debug and production
>modes? (Production mode being the time to supress NOTICE and
>perhaps WARNING errors)
>
>-Pollita
>
>> +1 on using trigger_error() in examples, including in mysql_connect.
>> +In
>> my experience, it needs more exposure to newbies as it is a far more
>> efficient way of dealing with errors. (And it actually took me a
>> couple years to discover it! :)
>>
>> And here is how I would do the code snippet
>>
>> if (!$conn = mysql_connect($host, $user, $pass)) {
>> trigger_error("Cannot connect: ". mysql_error(),
>E_USER_WARNING); }
>>
>> Note that I have it producing a warning instead of an error. That's
>> the way I do it, at least. ;)
>>
>> -Roy
>>
>> ----- Original Message -----
>> From: "Philip Olson" <philip@cornado.com>
>> To: "Gabor Hojtsy" <gabor@hojtsy.hu>
>> Cc: <john@coggeshall.org>; "'Sara Golemon'"
>> <php@alphaweb.net>;
>> <phpdoc@lists.php.net>
>> Sent: Monday, December 02, 2002 9:08 AM
>> Subject: Re: [PHP-DOC] Re: error handling [was: ugly cvs subject]
>>
>>
>>>
>>> I like the idea of trigger_error() and not using 'die'.
>Using 'die'
>>> in errors in unsexy and rather limiting but yes I remember we
>>> discussed this before too but it was only part of a huge discussion
>>> regarding the coding_standards RFC. I also feel 'or' for errors is
>>> unsexy and limiting. How about:
>>>
>>> if (!$conn = mysql_connect($host, $user, $pass)) {
>>> trigger_error("Cannot connect: ". mysql_error(), E_USER_ERROR); }
>>>
>>> Or will the !$conn part confuse people? Regardless, I agree if we
>>> don't use 'exit', and use trigger_error(), this would be a good
>>> thing. We would then update the trigger_error() docs so that even
>>> ultra newbies can understand them. Also the error would show by
>>> default still and be affected by the error_reporting
>>> function/directive. This is good. But, this brings up the
>point of
>>> should we use @ in examples, like, wouldn't the following be more
>>> appropriate?
>>>
>>> if (!$conn = @mysql_connect($host, $user, $pass)) {
>>> trigger_error("Cannot connect: ".mysql_error(), E_USER_ERROR); }
>>>
>>> I must admit my ignorance using trigger_error() and friends
>as I use
>>> my own but I'll mess with it a bit so I can better add to this
>>> discussion. Our examples should assume set_error_handler() is not
>>> being used but encourage its use and discuss how if the database is
>>> down how easy it is to show a pretty static html page
>instead. Maybe
>>> in a tutorial ;)
>>>
>>> Regards,
>>> Philip Olson
>>>
>>>
>>>
>>>
>
>
>
>
>