-
Notifications
You must be signed in to change notification settings - Fork 223
add inheritance exception mapping option #236
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
add inheritance exception mapping option #236
Conversation
6158213
to
b3347f8
Compare
I don't get exactly what's happening. |
In the current implementation it matches the on the exception fqcn that we put in the config and on the caught exception fqcn, so it is string comparison, it does not take inheritance into consideration. |
@hgraca can we try to make it more php native (maybe using instance of or so) then instead of keeping the string comparison? I'd even consider not making it optional, since it's a php behavior to treat exceptions with inheritance. |
Well, the code I added does exactly that, it tries to find a match using However, if we replace the existing string comparison, we will be changing expected behaviour which means it is a BC break, which means a major version bump, etc... Furthermore, the string comparison is much faster (it actually checks if the fqcn exists as an array key), so if it is already there, then we don't need to loop over the whole list of exceptions and to |
A way to make it faster is to use reflection, gather the class/interfaces/parents and then make an array intersection, but might be a bit overkill. |
b3347f8
to
44bea52
Compare
@renatomefi this is a sensitive change, this can result on security issues. I don't want to expose critical errors to users because of this, that's why I prefer leave the choice to developer to enable or not this feature in a first place. I agree error mapping need to be refactor... Next step will be to use native GraphQL PHP error handler but since the bundle implements this feature before the lib, we must not break compatibility. |
🎉 |
We would very much like to have the possibility of adding an exception to
overblog_graphql.definitions.exceptions.errors
and have its subclasses also be caught and handled by the ErrorHandler. (it would avoid us to explicitly add all exceptions to the config)This PR adds an option to the config, to do exactly that.