code -> sqlCode
This commit is contained in:
+3
-2
@@ -178,7 +178,7 @@ async function add(domain, data, auditSource) {
|
||||
];
|
||||
|
||||
[error] = await safe(database.transaction(queries));
|
||||
if (error && error.code === 'ER_DUP_ENTRY') throw new BoxError(BoxError.ALREADY_EXISTS, 'Domain already exists');
|
||||
if (error && error.sqlCode === 'ER_DUP_ENTRY') throw new BoxError(BoxError.ALREADY_EXISTS, 'Domain already exists');
|
||||
if (error) throw new BoxError(BoxError.DATABASE_ERROR, error);
|
||||
|
||||
await reverseProxy.setFallbackCertificate(domain, fallbackCertificate);
|
||||
@@ -298,7 +298,8 @@ async function del(domain, auditSource) {
|
||||
];
|
||||
|
||||
const [error, results] = await safe(database.transaction(queries));
|
||||
if (error && error.code === 'ER_ROW_IS_REFERENCED_2') {
|
||||
console.dir(error);
|
||||
if (error && error.sqlCode === 'ER_ROW_IS_REFERENCED_2') {
|
||||
if (error.message.includes('mailboxes_aliasDomain_constraint')) throw new BoxError(BoxError.CONFLICT, 'Domain is in use in a mailbox, list or an alias');
|
||||
if (error.message.includes('mailboxes_domain_constraint')) throw new BoxError(BoxError.CONFLICT, 'Domain is in use in a mailbox, list or an alias');
|
||||
if (error.message.includes('apps_mailDomain_constraint')) throw new BoxError(BoxError.CONFLICT, 'Domain is in use in an app\'s mailbox section');
|
||||
|
||||
Reference in New Issue
Block a user