-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throwable #1274
Throwable #1274
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
@@ -740,6 +740,7 @@ void zend_register_default_exception(void) /* {{{ */ | |||
base_exception_ce->create_object = NULL; | |||
memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); | |||
default_exception_handlers.clone_obj = NULL; | |||
zend_class_implements(base_exception_ce, 1, zend_ce_throwable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its spaces, wheras the code needs to be with tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
|
Closing in favor of #1284, which has been accepted. |