forked from strapi/strapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handle fileTooBig errors Signed-off-by: Pierre No毛l <petersg83@gmail.com> * add entityTooLarge error in provider plugins Signed-off-by: Pierre No毛l <petersg83@gmail.com> * fix linter Signed-off-by: Pierre No毛l <petersg83@gmail.com> * refacto Signed-off-by: Pierre No毛l <petersg83@gmail.com> * Add better error message for 413 errors in ML Signed-off-by: soupette <cyril.lpz@gmail.com> * refacto Signed-off-by: Pierre No毛l <petersg83@gmail.com> * refacto Signed-off-by: Pierre No毛l <petersg83@gmail.com> Co-authored-by: soupette <cyril.lpz@gmail.com>
- Loading branch information
Showing
18 changed files
with
3,996 additions
and
3,499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const errorTypes = { | ||
ENTITY_TOO_LARGE: 'entityTooLarge', | ||
UNKNOWN_ERROR: 'unknownError', | ||
}; | ||
|
||
const entityTooLarge = message => { | ||
const error = new Error(message || 'Entity too large'); | ||
error.type = errorTypes.ENTITY_TOO_LARGE; | ||
return error; | ||
}; | ||
entityTooLarge.type = errorTypes.ENTITY_TOO_LARGE; | ||
|
||
const unknownError = message => { | ||
const error = new Error(message || 'Unknown error'); | ||
error.type = errorTypes.UNKNOWN_ERROR; | ||
return error; | ||
}; | ||
unknownError.type = errorTypes.UNKNOWN_ERROR; | ||
|
||
const is = (err, errorFactory) => { | ||
return err.type && err.type === errorFactory.type; | ||
}; | ||
|
||
const convertToStrapiError = err => { | ||
if (is(err, entityTooLarge)) { | ||
return strapi.errors.entityTooLarge('FileTooBig', { | ||
errors: [ | ||
{ | ||
id: 'Upload.status.sizeLimit', | ||
message: 'file is bigger than the limit size!', | ||
}, | ||
], | ||
}); | ||
} else { | ||
strapi.log.error(err); | ||
return strapi.errors.badImplementation(); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
errors: { | ||
entityTooLarge, | ||
unknownError, | ||
}, | ||
convertToStrapiError, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { errors } = require('./errors'); | ||
|
||
module.exports = { | ||
errors, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.