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:
parent
d19182b583
commit
3a1a4caa78
@ -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;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user