code -> sqlCode
This commit is contained in:
+2
-2
@@ -73,8 +73,8 @@ async function add(backupId, data, auditSource) {
|
||||
const [error] = await safe(database.query('INSERT INTO archives (id, backupId, icon, appStoreIcon) VALUES (?, ?, ?, ?)',
|
||||
[ id, backupId, data.icon, data.appStoreIcon ]));
|
||||
|
||||
if (error && error.code === 'ER_NO_REFERENCED_ROW_2') throw new BoxError(BoxError.NOT_FOUND, 'Backup not found');
|
||||
if (error && error.code === 'ER_DUP_ENTRY') throw new BoxError(BoxError.ALREADY_EXISTS, 'Archive already exists');
|
||||
if (error && error.sqlCode === 'ER_NO_REFERENCED_ROW_2') throw new BoxError(BoxError.NOT_FOUND, 'Backup not found');
|
||||
if (error && error.sqlCode === 'ER_DUP_ENTRY') throw new BoxError(BoxError.ALREADY_EXISTS, 'Archive already exists');
|
||||
if (error) throw error;
|
||||
|
||||
await eventlog.add(eventlog.ACTION_ARCHIVES_ADD, auditSource, { id, backupId });
|
||||
|
||||
Reference in New Issue
Block a user