expand all parents of item that has an error

This commit is contained in:
Bruno Windels 2023-03-28 12:40:49 +02:00
parent ac9c244315
commit 30c0da3cd7

View File

@ -49,12 +49,26 @@ function filterValues(values: LogItemValues): LogItemValues | null {
}, null);
}
function hasChildWithError(item: LogItem): boolean {
if (item.error) {
return true;
}
if (item.children) {
for(const c of item.children) {
if (hasChildWithError(c)) {
return true;
}
}
}
return false;
}
function printToConsole(item: LogItem): void {
const label = `${itemCaption(item)} (@${item.start}ms, duration: ${item.duration}ms)`;
const filteredValues = filterValues(item.values);
const shouldGroup = item.children || filteredValues;
if (shouldGroup) {
if (item.error) {
if (hasChildWithError(item)) {
console.group(label);
} else {
console.groupCollapsed(label);