Skip to content

Commit ab96e71

Browse files
committed
add context to aggregator error strings
1 parent 82c5051 commit ab96e71

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lighthouse-core/aggregator/aggregate.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,26 @@ class Aggregate {
7777
typeof expected.rawValue === 'undefined' ||
7878
typeof expected.weight === 'undefined') {
7979
const msg =
80-
`Config for ${name} is undefined or does not contain rawValue and weight properties`;
80+
`aggregations: ${name} criteria does not contain expected rawValue or weight properties`;
8181
throw new Error(msg);
8282
}
8383

8484
if (typeof result === 'undefined' ||
8585
typeof result.score === 'undefined') {
86-
const msg =
87-
`Audit result for ${name} is undefined or does not contain score property`;
86+
let msg =
87+
`${name} audit result is undefined or does not contain score property`;
88+
if (result && result.debugString) {
89+
msg += ': ' + result.debugString;
90+
}
8891
throw new Error(msg);
8992
}
9093

9194
if (typeof result.score !== typeof expected.rawValue) {
92-
const msg =
95+
let msg =
9396
`Expected rawValue of type ${typeof expected.rawValue}, got ${typeof result.rawValue}`;
97+
if (result.debugString) {
98+
msg += ': ' + result.debugString;
99+
}
94100
throw new Error(msg);
95101
}
96102

0 commit comments

Comments
 (0)