# handling warnings/notices as elegantly as exceptions in php5

- Thread: https://externals.io/message/10866
- Original archive: https://news-web.php.net/php.internals/10866
- Started by Greg Beaver on 2004-07-01T23:33:15+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #10866 — Greg Beaver — 2004-07-01T23:33:15+00:00

URL: https://externals.io/message/10866#10866

Hello,

It is too early to do anything concrete, but I wonder if PHP 5.1 or 
later could add a non-fatal version of throw to handle 
warnings/errors/notices.

A `trigger_error()` that accepted an object similar to Exception would be 
a good solution.  This way, all the benefits of the Exception class 
could be used in a non-fatal context, without requiring a new language 
construct.  Overloading the function signature in this way would give 
complete customization, and would make the need for the hacks like 
PEAR_ErrorStack (however elegant) that we see all around us obsolete.

user error handlers would have to append another parameter that would 
contain the object passed in, in order to maintain proper BC, but that 
would be fine.

As Alan pointed out, there are no languages that provide both elegant 
Exception and elegant warning/notice handling, perhaps PHP5 could be the 
first.

Thanks,
Greg
