Hello!

This is my first post to the internals list so please forgive me if I have
not followed the rules precisely!

I've had an idea to improve how developers use exceptions within PHP. I'd
like to add an RFC but as per the instructions on the site
<https://wiki.php.net/rfc/howto>, I am sending this email first gauge
reaction as an initial idea.

The idea is to change the base Exception
<http://php.net/manual/en/class.exception.php> class to be abstract. The
reason for this is to encourage developers to extend it to create meaning
exceptions or use the standard SPL exceptions. The documentation states
that it's the base class for all exceptions, which kind of encourages my
thought process.

Too many times have I seen developers throwing Exceptions when what they
really needed was something that gave it context like
InvalidArgumentException or RuntimeException. Yes, I agree this is
something to tackle at code review (and I do) but I feel PHP doesn't help
the situation by making it an instantiatable class. I struggle to think of
a valid reason where it makes sense to throw the root Exception class.
Catching the root Exception class is a different matter and there are
perfectly valid cases for doing it.

So, what does everyone think? Is it worth me pursing the RFC with full
details of the idea or am I on my own with this one?

Many thanks!
Kevin

Reply via email to