2
0
mirror of https://github.com/frappe/books.git synced 2024-12-25 20:11:15 +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) { getError(err) {
let errorType = frappe.errors.DatabaseError;
if (err.message.includes('FOREIGN KEY')) { if (err.message.includes('FOREIGN KEY')) {
return frappe.errors.LinkValidationError; errorType = frappe.errors.LinkValidationError;
} }
if (err.message.includes('SQLITE_ERROR: cannot commit')) { if (err.message.includes('SQLITE_ERROR: cannot commit')) {
return frappe.errors.CannotCommitError; errorType = frappe.errors.CannotCommitError;
} }
return ( if (err.message.includes('SQLITE_CONSTRAINT: UNIQUE constraint failed:')) {
{ errorType = frappe.errors.DuplicateEntryError;
19: frappe.errors.DuplicateEntryError }
}[err.errno] || Error return errorType;
);
} }
} }