mirror of
https://github.com/strapi/strapi.git
synced 2025-08-14 03:34:53 +00:00
18 lines
374 B
JavaScript
18 lines
374 B
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
const isDuplicateEntryError = error => {
|
||
|
return error.code === 11000; // MongoDB code for duplicate key error
|
||
|
};
|
||
|
|
||
|
const handleDatabaseError = error => {
|
||
|
if (isDuplicateEntryError(error)) {
|
||
|
strapi.log.warn('Duplicate entry', error.toString());
|
||
|
throw new Error('Duplicate entry');
|
||
|
}
|
||
|
throw error;
|
||
|
};
|
||
|
|
||
|
module.exports = {
|
||
|
handleDatabaseError,
|
||
|
};
|