Re: Exceptions Vs Errors

From: Date: Tue, 04 Sep 2012 15:30:39 +0000
Subject: Re: Exceptions Vs Errors
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-62800@lists.php.net to get a copy of this message
2012/9/3 Lester Caine <lester@lsces.co.uk>: > more ... try/catch always seems like 'I can't be bothered so just do this if > you can' where it would be much tidier if file_put_contents(); was written > so it simply finished with an error if it has a problem? Hm. I want to bring in some thoughts. Perhaps I have not the right words to describe what I mean, but there are 3 things which come in my mind when PHP may switch the error-handling to any kind of exceptions: 1. Current error-handling has it's advantages. Ideal for short programs. I don't wanna miss it. I need to ignore errors completely. 2. I think - prove me wrong :) - it is not possible to change the hole error-handling from one PHP-version to another, especially when the behavior changes so entirely. I think it will take some time. Maybe we have to live with a mixture (new exceptions and old error-handling) for some time? 3. Why not having this as concept? Maybe it's a good strategy to enable both: current error-handling and having exceptions? The rest is logic: When I want to enable to handle an exception like an PHP-error, I need to tell PHP during the creation of the error, that it should not handle it like an exception. Ok, ok, as Rasmus correctly mentioned, uncaught exceptions are by definition fatal. But isn't catching an exception not like "I know how to handle it?" And when I know how to handle it, couldn't I handle it in the exception directly? More questions than answers so far. -- Alex Aulbach

« previous php.internals (#62800) next »