-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Continue throwing same exception when edit entity #5959
Conversation
Thanks for this proposal ... but I'm not sure if we can merge this "as is" without breaking things for other people 🤔 |
In both cases you trigger Exception. BadRequestHttpException is used only in the edit form. Also everyone read the change log before update. |
I agree with @javiereguiluz, this would a BC break, so at the very least it'll need to go into 5.x. I also agree that people should be reading the change log, but semantic versioning exists so that you only have to read the change log for major version updates. No one is reading the change log for every minor version up for every package they depend on. However, I'm not sure what value it provides. @abozhinov can you please provide some more details and maybe an example of what you're trying to acomplish? I think, given that this is a controller, it shouldn't be throwing random exceptions. It's meant to throw HttpExceptions so that the correct http status code is returned. If you're trying to catch specific exceptions, could you instead override this method in your CrudController? for example: public function edit(AdminContext $context)
{
try {
return parent::edit($context);
} catch (BadRequestHttpException $e) {
// some custom logic
}
if ($event->isPropagationStopped()) {
return $event->getResponse();
}
return new Response($newValue ? '1' : '0');
} |
Hi,
If you think this change can break something let's set Message to BadRequestHttpException? |
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.
Thanks for the extra detail. I think this is a much better solution!
Things are more clear to me now ... and the updated code looks safer to merge 🙌 Thanks Alexandar! |
Now I have event listener and throw exception, but the exception is stopped by the controller and replace with BadRequestHttpException.