From 499efb5ce0a1a52d4a2b7d14bbc9e58e9aaf2edd Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 18 Feb 2021 13:07:12 +0100 Subject: [PATCH] add error and status to caption in logviewer --- scripts/logviewer/main.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/logviewer/main.js b/scripts/logviewer/main.js index f22890fa..e621b5d8 100644 --- a/scripts/logviewer/main.js +++ b/scripts/logviewer/main.js @@ -128,11 +128,22 @@ function itemLevel(item) { return item.l; } function itemLabel(item) { return item.v?.l; } function itemType(item) { return item.v?.t; } function itemError(item) { return item.e; } +function itemShortErrorMessage(item) { + if (itemError(item)) { + const e = itemError(item); + return e.name || e.stack.substr(0, e.stack.indexOf("\n")); + } +} + function itemCaption(item) { if (itemType(item) === "network") { return `${itemValues(item)?.method} ${itemValues(item)?.url}`; } else if (itemLabel(item) && itemValues(item)?.id) { return `${itemLabel(item)} ${itemValues(item).id}`; + } else if (itemLabel(item) && itemValues(item)?.status) { + return `${itemLabel(item)} (${itemValues(item).status})`; + } else if (itemLabel(item) && itemError(item)) { + return `${itemLabel(item)} (${itemShortErrorMessage(item)})`; } else { return itemLabel(item) || itemType(item); }