Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Do not trigger errors when a block doesn't exist anymore #1115
Do not trigger errors when a block doesn't exist anymore #1115
Changes from all commits
32d138b
d073eb3
9562a7a
3309860
9619f99
d06eff4
09b63bf
1ef7a68
cd0a0bb
373de4a
0000861
c14664c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Should it extend from http exception 🤔
If yes then we should add NotFoundHttpException as Suffix?!
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.
Maybe not, I copied the old exception. And what about that ?
Or simply :
Let me know and I'll do modifications tomorrow morning
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.
it needs to extend some kind of exception. If you also implement the BlockExceptionInterface maybe thats enough to render empty response automatically? or not?
I feel like the whole exception catching should happen in the block bundle, are you sure you want to introduce specific logic for page @VincentLanglet ?
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.
Hey @jordisala1991, do you mean here https://github.com/sonata-project/SonataBlockBundle/blob/4.x/src/Templating/Helper/BlockHelper.php#L388 ?
But if we do this, we can't handle the exception for code that uses this method, if for some reason I need to implement some logical if the block doesn't exist, I can't do that, because I never get the exception!
usually I handle the exception in the last layer before to return to client.
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.
First I dunno why BlockNotFound extends NotFoundException, it feels weird https://github.com/sonata-project/SonataBlockBundle/blob/4.x/src/Exception/BlockNotFoundException.php#L18
I mean, I don't see how we're in a Http context here:
SonataBlockBundle/src/Block/BlockLoaderChain.php
Line 66 in 375b168
And indeed there is a BlockExceptionInterface.
Seems like a strategy exist to ignore block exceptions https://github.com/sonata-project/SonataBlockBundle/blob/987d2936d3d2a3d4fe4615241f545aad693eb4c2/docs/reference/exceptions.rst#filters
So indeed, throwing a BlockServiceNotFound extends BlockExceptionInterface would allow people to ignore this exception with the correct filter.
It might require some conf in PageBundle still to use the correct filter.
But again, I asked a question and got no answer so far:
which filter and which renderer is using SonataPageBundle.
https://github.com/sonata-project/SonataBlockBundle/blob/987d2936d3d2a3d4fe4615241f545aad693eb4c2/docs/reference/exceptions.rst#exception-strategy
IMHO, blockbundle should allow to ignore them (with specific exception/config) and pagebundle should activate this ; and this already a feature from blockbundle.
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.
After @JeromeEngelnAdeliom change it, I'll test in sonata page bundle, and check if those configs works as expected :D
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.
Ten years ago #36 :(
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.
@eerison wdyt about using
extends \UnexpectedValueException
? it seems to match with our missing block service case.=> Exception thrown if a value does not match with a set of values. Typically this happens when a function calls another function and expects the return value to be of a certain type or value not including arithmetic or buffer related errors.
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.
IMO
BlockServiceNotFoundException
isn't an abstraction ofUnexpectedValueException
👀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.
Extending Exception is enough.
And fun fact, @jordisala1991, https://github.com/sonata-project/SonataBlockBundle/blob/4.x/src/Exception/BlockExceptionInterface.php#L19 is currently not extending Throwable...