diff --git a/src/public/app/dialogs/add_link.js b/src/public/app/dialogs/add_link.js index 13798a3c6..4f29bb39a 100644 --- a/src/public/app/dialogs/add_link.js +++ b/src/public/app/dialogs/add_link.js @@ -86,7 +86,7 @@ $form.on('submit', () => { textTypeWidget.addLink(notePath, linkTitle); } else { - console.error("No path to add link."); + logError("No path to add link."); } return false; diff --git a/src/public/app/dialogs/clone_to.js b/src/public/app/dialogs/clone_to.js index de82c50b5..6ac6af422 100644 --- a/src/public/app/dialogs/clone_to.js +++ b/src/public/app/dialogs/clone_to.js @@ -61,7 +61,7 @@ $form.on('submit', () => { cloneNotesTo(notePath); } else { - console.error("No path to clone to."); + logError("No path to clone to."); } return false; diff --git a/src/public/app/dialogs/include_note.js b/src/public/app/dialogs/include_note.js index 1aa2b149e..9f92c3a92 100644 --- a/src/public/app/dialogs/include_note.js +++ b/src/public/app/dialogs/include_note.js @@ -46,7 +46,7 @@ $form.on('submit', () => { includeNote(notePath); } else { - console.error("No noteId to include."); + logError("No noteId to include."); } return false; diff --git a/src/public/app/dialogs/move_to.js b/src/public/app/dialogs/move_to.js index 21b2ebdd8..9d5408818 100644 --- a/src/public/app/dialogs/move_to.js +++ b/src/public/app/dialogs/move_to.js @@ -51,7 +51,7 @@ $form.on('submit', () => { treeCache.getBranchId(parentNoteId, noteId).then(branchId => moveNotesTo(branchId)); } else { - console.error("No path to move to."); + logError("No path to move to."); } return false; diff --git a/src/public/app/services/bundle.js b/src/public/app/services/bundle.js index 691562b69..1ab93ded8 100644 --- a/src/public/app/services/bundle.js +++ b/src/public/app/services/bundle.js @@ -64,7 +64,7 @@ async function getWidgetBundlesByParent() { widget = await executeBundle(bundle); } catch (e) { - console.error("Widget initialization failed: ", e); + logError("Widget initialization failed: ", e); continue; } diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js index 2ff1485fa..aefc42efd 100644 --- a/src/public/app/services/link.js +++ b/src/public/app/services/link.js @@ -11,7 +11,7 @@ function getNotePathFromUrl(url) { async function createNoteLink(notePath, options = {}) { if (!notePath || !notePath.trim()) { - console.error("Missing note path"); + logError("Missing note path"); return $("").text("[missing note]"); } diff --git a/src/public/app/services/tab_context.js b/src/public/app/services/tab_context.js index d47a47721..196a52cfe 100644 --- a/src/public/app/services/tab_context.js +++ b/src/public/app/services/tab_context.js @@ -36,7 +36,7 @@ class TabContext extends Component { resolvedNotePath = await treeService.resolveNotePath(inputNotePath); if (!resolvedNotePath) { - console.error(`Cannot resolve note path ${inputNotePath}`); + logError(`Cannot resolve note path ${inputNotePath}`); return; } diff --git a/src/public/app/services/tree.js b/src/public/app/services/tree.js index bc1b3e0a7..8e285c5e6 100644 --- a/src/public/app/services/tree.js +++ b/src/public/app/services/tree.js @@ -62,7 +62,7 @@ async function resolveNotePathToSegments(notePath, logErrors = true) { if (!parents.length) { if (logErrors) { - ws.logError(`No parents found for ${childNoteId}`); + ws.logError(`No parents found for ${childNoteId} (${child.title})`); } return; @@ -70,7 +70,9 @@ async function resolveNotePathToSegments(notePath, logErrors = true) { if (!parents.some(p => p.noteId === parentNoteId)) { if (logErrors) { - console.log(utils.now(), `Did not find parent ${parentNoteId} for child ${childNoteId}, available parents: ${parents.map(p => p.noteId)}`); + const parent = treeCache.getNoteFromCache(parentNoteId); + + console.log(utils.now(), `Did not find parent ${parentNoteId} (${parent ? parent.title : 'n/a'}) for child ${childNoteId} (${child.title}), available parents: ${parents.map(p => `${p.noteId} (${p.title})`)}`); } const someNotePath = getSomeNotePath(parents[0]); @@ -113,7 +115,7 @@ function getSomeNotePath(note) { const parents = cur.getParentNotes(); if (!parents.length) { - console.error(`Can't find parents for note ${cur.noteId}`); + logError(`Can't find parents for note ${cur.noteId}`); return; } @@ -196,7 +198,7 @@ function getNoteIdAndParentIdFromNotePath(notePath) { function getNotePath(node) { if (!node) { - console.error("Node is null"); + logError("Node is null"); return ""; } diff --git a/src/public/app/services/tree_cache.js b/src/public/app/services/tree_cache.js index 27815d4d8..ad642e89c 100644 --- a/src/public/app/services/tree_cache.js +++ b/src/public/app/services/tree_cache.js @@ -267,7 +267,7 @@ class TreeCache { getBranch(branchId, silentNotFoundError = false) { if (!(branchId in this.branches)) { if (!silentNotFoundError) { - console.error(`Not existing branch ${branchId}`); + logError(`Not existing branch ${branchId}`); } } else { @@ -283,7 +283,7 @@ class TreeCache { const child = await this.getNote(childNoteId); if (!child) { - console.error(`Could not find branchId for parent=${parentNoteId}, child=${childNoteId} since child does not exist`); + logError(`Could not find branchId for parent=${parentNoteId}, child=${childNoteId} since child does not exist`); return null; } diff --git a/src/public/app/services/ws.js b/src/public/app/services/ws.js index ad66eeb42..afcff6216 100644 --- a/src/public/app/services/ws.js +++ b/src/public/app/services/ws.js @@ -19,8 +19,7 @@ let lastPingTs; let syncDataQueue = []; function logError(message) { - console.log(utils.now(), message); // needs to be separate from .trace() - console.trace(); + console.error(utils.now(), message); // needs to be separate from .trace() if (ws && ws.readyState === 1) { ws.send(JSON.stringify({ @@ -31,6 +30,8 @@ function logError(message) { } } +window.logError = logError; + function subscribeToMessages(messageHandler) { messageHandlers.push(messageHandler); } diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index f0627db58..39e4b52be 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -406,7 +406,7 @@ export default class NoteTreeWidget extends TabAwareWidget { notes = JSON.parse(jsonStr); } catch (e) { - console.error(`Cannot parse ${jsonStr} into notes for drop`); + logError(`Cannot parse ${jsonStr} into notes for drop`); return; } @@ -809,7 +809,7 @@ export default class NoteTreeWidget extends TabAwareWidget { if (!resolvedNotePathSegments) { if (logErrors) { - console.error("Could not find run path for notePath:", notePath); + logError("Could not find run path for notePath:", notePath); } return; @@ -1152,11 +1152,17 @@ export default class NoteTreeWidget extends TabAwareWidget { async setExpanded(branchId, isExpanded) { utils.assertArguments(branchId); - const branch = treeCache.getBranch(branchId); + const branch = treeCache.getBranch(branchId, true); if (!branch) { - // in case of virtual branches there's nothing to update - return; + if (branchId && branchId.startsWith('virt')) { + // in case of virtual branches there's nothing to update + return; + } + else { + logError(`Cannot find branch=${branchId}`); + return; + } } branch.isExpanded = isExpanded; diff --git a/src/public/app/widgets/type_widgets/relation_map.js b/src/public/app/widgets/type_widgets/relation_map.js index 0c01e1e43..dbb7d0516 100644 --- a/src/public/app/widgets/type_widgets/relation_map.js +++ b/src/public/app/widgets/type_widgets/relation_map.js @@ -539,7 +539,7 @@ export default class RelationMapTypeWidget extends TypeWidget { const note = this.mapData.notes.find(note => note.noteId === noteId); if (!note) { - console.error(`Note ${noteId} not found!`); + logError(`Note ${noteId} not found!`); return; }