Re: Why do disabled functions / classes generate a WARNING.
| From: | Stan Vass | Date: | Fri, 03 Aug 2012 16:42:00 +0000 |
| Subject: | Re: Why do disabled functions / classes generate a WARNING. | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62016@lists.php.net to get a copy of this message | ||
Which brings up the issues that I mentioned before.
Getting the return of an erroring function isn't such a big issue, but turning everything
into exceptions would prevent getting any return value from any function/operation which triggers
anything,
Maybe you want to keep your cake and eat it too, but in practice, functions which return useful
content and also error are simply poorly designed.
You can work around such function, for example if I absolutely need both channels, exception AND
return value, I have this:
1) switch the error handler in a temporary mode which logs errors in an array without throwing them.
2) call the offending function
3) preserve the return value and read the log
4) create an exception class instance which contains all needed data
5) throw it.
Alternatively I can choose to just return the value and not throw anything, depends what makes most
sense. I wrap this once and then I can call it just as usual, getting both channels. BUT, this is
very rare, and is a sign of a poor design of the function IMHO.
Stan