> Should error handling be completely
exception-dominated? Is there any
> role for success/failure return values in a language with exception support?
1) No.
2) Yes.
the general answer is that exceptions should only be
used
for exceptional circumstances, and likely failures are better off
handled with return codes.
I fully agree with that. Don't use exceptions for something you
regularly _expect_ to happen in your software like in the example of the
first post.
The reasons I know are:
* You mask the control flow of the application. Some other developer
reading your code will easier understand some if-else structure instead
of a block of code, where the control flow is dictated indirectly by
exception handling.
* Exception handling has high runtime costs in most languages (if it
actually occurs), as far as I know. But I don't know, if that's also
true for PHP.
* From personal experience with foreign code I'd say: If exception
handling is used very often throughout the code of a project, then
people tend to put exception handling around _everything_, even if there
is actually no chance to handle the exceptional event in a meaningful
way and it would be better to just return an error, to terminate the
code or to have some other fallback strategy.
Ciao, Michael.