2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

fix: Better check for DuplicateEntryError

This commit is contained in:
Faris Ansari 2019-12-20 11:48:53 +05:30
parent d19182b583
commit 3a1a4caa78

View File

@ -91,17 +91,17 @@ class SqliteDatabase extends Database {
}
getError(err) {
let errorType = frappe.errors.DatabaseError;
if (err.message.includes('FOREIGN KEY')) {
return frappe.errors.LinkValidationError;
errorType = frappe.errors.LinkValidationError;
}
if (err.message.includes('SQLITE_ERROR: cannot commit')) {
return frappe.errors.CannotCommitError;
errorType = frappe.errors.CannotCommitError;
}
return (
{
19: frappe.errors.DuplicateEntryError
}[err.errno] || Error
);
if (err.message.includes('SQLITE_CONSTRAINT: UNIQUE constraint failed:')) {
errorType = frappe.errors.DuplicateEntryError;
}
return errorType;
}
}