Re: E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, January 4, 2007 6:17 pm, Roman Neuhauser wrote:
> # ceo@xxxxxxxxx / 2007-01-04 16:34:46 -0600:
>> You end up catching somebody else's error and handling it, even
>> though
>> what you THINK has gone wrong is not at all what actually went
>> wrong,
>> because they didn't write a try/catch handler where they should
>> have.
>
> Yeah, that can lead to unexpected behavior. It still helps prevent
> crashes.
>
>> try {
>>   if (something($whatever)){
>>     $file = fopen("/some/path/or/other", 'r');
>>   }
>> }
>> catch ($e){
>>   //handle error from opening $file
>> }
>>
>> Then later on after that (possibly weeks/months/years) some other
>> programmer (or yourself) changes the 'whatever' function to use
>> fopen() to open a file, but does NOT wrap that in a try/catch
>> because
>> it's some silly little file that "has to work"
>
> Ok, but what harm has been done? something() presumably did the
> fopen()
> for a reason, and couldn't work without the file handle and couldn't
> succeed anyway.
>
> Sure, the program leaves the normal path at this moment unexpectedly,
> and I can understand your frustration, but it has a bug, right? And
> although the program contains a bug it hasn't crashed, it just entered
> whatever orderly cleanup-and-exit path you had prepared.
>
> If fopen() didn't throw and the programmer didn't check the return
> value
> (catch the exception in your version), you'd be screwed not even
> knowing
> it.
>
> I think you brought a solid example of superiority of exceptions over
> returning error codes.

over returning error codes and not DOING anything with them?  Sure.

Over well-written code that does something with the returned error
codes? no.  Just a stylistic difference really, if all developers
consistently did their error-checking, and did it fairly well.

Alas, they don't.

And, suppose it's NOT an fopen() that was the problem deep in the guts
of the other guy's code.

Now you are catching an error and you have NO IDEA what the [bleep] to
do with it.

At least with error code returns, you are USUALLY dealing with a
specific way to get those codes (in PHP, not C-style shell-style
pass-the-buck error code bubble-up).

And, of course, you just ignored the question of another catch block
doing something you wish it didn't do...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux