-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Resolving middleware breaks if resolver throws unexpected exception type #3071
Comments
I'm not sure if silencing all exceptions thrown by callable resolver is the best idea, personally. Having a dedicated interface for this would be better, but it would also introduce a possible breaking change for callable resolver implementors. something like this: if ($this->callableResolver instanceof CallableResolverInterface) {
try {
$callable = $this->callableResolver->resolve($this->middleware);
} catch (UnableToResolveCallableExceptionInterface $e) {
// Do Nothing
}
}
|
@dakujem note that there is already |
This is exactly why. Ultimately in Slim 5 we should get rid of
This is unfortunately technical debt that needs to be resolved in Slim 5.
I don't think that this is correct. We need to specifically ensure that the exception thrown is because the callable could not be resolved and not do a catch-all because we have no idea what's happening downstream. We will need a named exception like |
I follow the sentiment. The current implementation neither ensures that distinction or lets fallback code be consistently reached. My initial thought was to prioritize reaching fallback code since that would make more cases work. Making more cases fail clearly does not look possible without introducing a new exception and having to rewrite existing interface implementers. At which point they could as well update to advanced interface. |
CallableResolver
call is wrapped in a catch that expectsRuntimeException
Slim/Slim/MiddlewareDispatcher.php
Lines 214 to 222 in 8294d20
If a resolver throws exception that doesn't extend from
RuntimeException
this halts the execution and fallback code below is never reached.Real example of the issue with third party resolver: PHP-DI/Slim-Bridge#51
I am not sure what's the reasoning for specifically
RuntimeException
here, but broadening it toException
might be a good idea for resilience?The text was updated successfully, but these errors were encountered: