mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
improvements to error logging in frontend
This commit is contained in:
parent
c71ac0302a
commit
d953d96fa6
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -46,7 +46,7 @@ $form.on('submit', () => {
|
||||
includeNote(notePath);
|
||||
}
|
||||
else {
|
||||
console.error("No noteId to include.");
|
||||
logError("No noteId to include.");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 $("<span>").text("[missing note]");
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 "";
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,12 +1152,18 @@ 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) {
|
||||
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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user