Throwable#1274
Throwable#1274sebastianbergmann wants to merge 4 commits intophp:masterfrom sebastianbergmann:throwable
Conversation
sebastianbergmann
commented
May 13, 2015
… is also used to register interfaces that are not related to iterators)
* Rename EngineException to EngineError and let it extend Error * Rename ParseException to ParseError and let it extend Error * Rename TypeException to TypeError and let it extend Error
There was a problem hiding this comment.
its spaces, wheras the code needs to be with tabs.
There was a problem hiding this comment.
Would be great if we could focus on conceptual problems and implementation issues before critiquing whitespace.
|
I'm not sure about the naming change from Exception to Error. Could you elaborate a bit more on the semantics of Error? Is user-land allowed to raise errors? Can they extend them? Etc? |
|
Also, note that Java's exception hiearchy is sh*t. Checked errors are a super class of unchecked ones: catch(Exception amICheckedOrUnchecked){
if(amICheckedOrUnchecked instanceof RuntimeException){
throw amICheckedOrUnchecked; // sorry this can't be handled
}
// actual handling here -__-
} |
|
@sebastianbergmann Anyway, +1 for the |
|
What's the reason for having a |
|
@nikic So what's the reason for having a |
|
Linking to the relevant RFC: https://wiki.php.net/rfc/throwable Based on the above RFC, the goal is to make
|
|
I looked into how separate exception classes could be implemented with only a common interface and it seems like there would be a lot of unnecessary duplication. Having Perhaps a hierarchy like the one below would be more acceptable? This is similar to what has already been implemented in PHP 7, except
Edit: This was so straightforward to implement, I quickly did it here: https://github.com/trowski/php-src/tree/throwable Many tests would need to be updated yet, but for the most part find and replace would do the job. |
|
IMO the "new" error exceptions, be that And at the same time and for reasons of BC, The current hierarchy, where you have That part isn't apparent from https://wiki.php.net/rfc/throwable; it says "Error class" in the title, but only mentions that both I like And with an Thusly:
Or:
|
|
@dzuelke i agree that Error suffix must be adopted, but i don't agree on the hiearchy. say you want to catch a fatal error to log it / send it to debugger, ok? |
|
Yeah, |
That's a good thing, IMO. |
|
it doesn't make sense to make a distinction between exceptions thrown by the engine and those that are user-defined |
Unfortunately we probably should for BC reasons. Exceptions thrown by the engine shouldn't directly extend |
|
Just to document my opinion somewhere: I think anyone doing It's a BC break either way. Just make them all extend Exception and preserve existing catch-all behaviors. |
No, but they were written with the expectation they would catch all exceptions, both current and future. |
Please provide an logical argument of how it is more "clean" than if |
|
@morrisonlevi Because the |
|
@trowski: Why Throwable wouldn't be an interface but a class? I don't like 2015-05-16 7:08 GMT+02:00 Aaron Piotrowski notifications@github.com:
|