-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adding exception interfaces #22
Comments
I'm +1 on the Definition Exception but for the invalid arguments can't we just use a core InvalidArgumentException? |
Im too for core InvalidArgumentException don't add to much interfaces :D |
Custom exceptions are only useful to be caught (so that we can catch those exceptions and not others). Why would we want to catch those exceptions? |
Mmmmm... good point. I should maybe review my exceptions best practices :) We should then maybe just write in the spec (when we will write it) that compilers/containers MUST throw an InvalidArgumentException if provided with an invalid definition or an invalid argument. We might still keep the base Please note I have no strong opinion on this, I was simply trying to write the unit tests and noticed this was something we did not discuss before. |
I think basing the exceptions on actual use cases as @mnapoli said would be best, I think currently in Assembly there's only one, the |
Let's put it another way: before adding an exception we should think how it would be justified in a meta document.
I just want to point out that we don't care what exceptions containers will throw when reading standard definitions, because it's already out of the scope of this standard (it's happening in a container when resolving definitions, and here we don't define container parts that do the resolving). |
Hey Matthieu, I think I understand your point. At least, I can tell you why a container consuming Now, I also understand your point.
I honestly don't know. I've been trying to figure out a valid use case, but the truth is I can't. So you are probably right that defining a I'm ok to close this issue now, but first, I'd like to know what I should do with the unit test here: Are we ok that the container/compiler should throw an exception (and we don't care about the exception type). Or should we simply remove the test? |
To me it's not. The point of this PSR is to allow packages to create universal definitions, if we start having definitions that have additional features only supported by container X or Y, we're back to square one really. |
Enforce that `DefinitionProviderInterface::getDefinitions()` returns an array of `DefinitionInterface`.
I've opened #23 for that. The interface was lacking such precision, now it should be good. The fact that we can't strictly enforce that at the compilation level in PHP is just because PHP doesn't support this. But the interface specifies the return type in phpdoc. Implementation that do not respect that are just not compliant.
This is out of scope. We are standardizing definitions, not containers consuming these definitions.
This test should be removed IMO. |
While working on definition-interop implementation, I found 2 places where exceptions could potentially be triggered:
DefinitionProviderInterface
might send back objects that are not one of the valid definitions (for instance, it might return astdClass
. In this case, we might want to throw aInvalidDefinition
exception.stdClass
to theMethodCall::addArgument
method, which is invalid too. In this case, we might want to throw aInvalidArgument
exception.These could be simple empty interfaces:
Shall I write a PR for this?
If yes, I'll also have to modify the unit test to test for these interfaces.
Also, what about the naming? Sall I suffix those with "Exception"? Or even worse, with ExceptionInterface? :) ... mmmm.... suffixes :)
The text was updated successfully, but these errors were encountered: