mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-05-21 21:48:25 -05:00
improved error handling
This commit is contained in:
@@ -895,6 +895,10 @@ async function asyncPostProcessContent(note, content) {
|
||||
|
||||
// all keys should be replaced by the corresponding values
|
||||
function replaceByMap(str, mapObj) {
|
||||
if (!mapObj) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const re = new RegExp(Object.keys(mapObj).join("|"),"g");
|
||||
|
||||
return str.replace(re, matched => mapObj[matched]);
|
||||
|
||||
@@ -93,7 +93,7 @@ async function setupSyncFromSyncServer(syncServerHost, syncProxy, password) {
|
||||
return { result: 'success' };
|
||||
}
|
||||
catch (e) {
|
||||
log.error(`Sync failed: ${e.message}`);
|
||||
log.error(`Sync failed: '${e.message}', stack: ${e.stack}`);
|
||||
|
||||
return {
|
||||
result: 'failure',
|
||||
|
||||
@@ -71,8 +71,7 @@ async function sync() {
|
||||
};
|
||||
}
|
||||
else {
|
||||
log.info(`sync failed: ${e.message}
|
||||
stack: ${e.stack}`);
|
||||
log.info(`Sync failed: '${e.message}', stack: ${e.stack}`);
|
||||
|
||||
ws.syncFailed();
|
||||
|
||||
|
||||
@@ -46,6 +46,10 @@ function updateNormalEntity(remoteEC, remoteEntityRow, instanceId) {
|
||||
}
|
||||
|
||||
if (!localEC || localEC.utcDateChanged <= remoteEC.utcDateChanged) {
|
||||
if (!remoteEntityRow) {
|
||||
throw new Error(`Empty entity row for: ${JSON.stringify(remoteEC)}`);
|
||||
}
|
||||
|
||||
if (remoteEC.entityName === 'blobs' && remoteEntityRow.content !== null) {
|
||||
// we always use a Buffer object which is different from normal saving - there we use a simple string type for
|
||||
// "string notes". The problem is that in general, it's not possible to detect whether a blob content
|
||||
@@ -59,10 +63,6 @@ function updateNormalEntity(remoteEC, remoteEntityRow, instanceId) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!remoteEntityRow) {
|
||||
throw new Error(`Empty entity row for: ${JSON.stringify(remoteEC)}`);
|
||||
}
|
||||
|
||||
sql.replace(remoteEC.entityName, remoteEntityRow);
|
||||
|
||||
if (!localEC || localEC.utcDateChanged < remoteEC.utcDateChanged) {
|
||||
@@ -81,6 +81,10 @@ function updateNormalEntity(remoteEC, remoteEntityRow, instanceId) {
|
||||
}
|
||||
|
||||
function updateNoteReordering(remoteEC, remoteEntityRow, instanceId) {
|
||||
if (!remoteEntityRow) {
|
||||
throw new Error(`Empty note_reordering body for: ${JSON.stringify(remoteEC)}`);
|
||||
}
|
||||
|
||||
for (const key in remoteEntityRow) {
|
||||
sql.execute("UPDATE branches SET notePosition = ? WHERE branchId = ?", [remoteEntityRow[key], key]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user