Merge pull request #13976 from strapi/fix/upload-proxy-error-gracefully

Upload: Handle file upload errors gracefully
This commit is contained in:
Gustav Hansen 2022-08-04 16:38:17 +02:00 committed by GitHub
commit eb7dbd39d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -108,10 +108,21 @@ export const UploadingAssetCard = ({
</Card>
{error ? (
<Typography variant="pi" fontWeight="bold" textColor="danger600">
{formatMessage({
id: getTrad(`apiError.${error.response.data.error.message}`),
defaultMessage: error.response.data.error.message,
})}
{formatMessage(
error?.response?.data?.error?.message
? {
id: getTrad(`apiError.${error.response.data.error.message}`),
defaultMessage: error.response.data.error.message,
/* See issue: https://github.com/strapi/strapi/issues/13867
A proxy might return an error, before the request reaches Strapi
and therefore we need to handle errors gracefully.
*/
}
: {
id: getTrad('upload.generic-error'),
defaultMessage: 'An error occured while uploading the file.',
}
)}
</Typography>
) : (
undefined

View File

@ -1,5 +1,6 @@
{
"apiError.FileTooBig": "The uploaded file exceeds the maximum allowed asset size.",
"upload.generic-error": "An error occurred while uploading the file.",
"bulk.select.label": "Select all assets",
"button.next": "Next",
"checkControl.crop-duplicate": "Duplicate & crop the asset",