- Notifications
You must be signed in to change notification settings - Fork 9.4k
improve Magento\Catalog\Model\ImageUploader error handler #27179
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
Conversation
Hi @fsw. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
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.
I agree with adding logging, but for security reasons we dont want to expose additional info.
Yes but additional info is hidden anyway in production mode (witch is indeed great for security). I think showing stack in developer mode and logging it in production and showing generic message is a good logic and can't see why we should treat some cases differently. |
|
@lenaorobei , way of handling exceptions is of course disputable hence I was wondering is there any official Magento guidance for it. Because without this specific try/catch:
And with it:
hence I think first option is better. |
QA notes: please make sure that extended message is shown in developer mode only. |
Hi @lenaorobei, thank you for the review.
|
✔️ QA Passed |
Failed functional tests not related to the changes in this PR |
Hi @fsw, thank you for your contribution! |
Description (*)
Magento\Catalog\Model\ImageUploader is catching detailed exceptions and turning it into generic "Something went wrong while saving the file(s)." Data on what actually went wrong is gone.
This fix logs exception and passes previous exception to constructor not to loose this info.
Also I would like to discuss if there are some guidelines on handling such cases in Magento 2.
In my humble opinion in development mode we show detailed info and in production mode we show "something went wrong" and log exception so catching exception just to show "Something went wrong while saving the file" in both modes and loose debug info does not make much sense and I would remove both this try/catches at all.
Manual testing scenarios (*)
Contribution checklist (*)