Skip to content

Commit

Permalink
add context to aggregator error strings
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Aug 17, 2016
1 parent 82c5051 commit ab96e71
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lighthouse-core/aggregator/aggregate.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,26 @@ class Aggregate {
typeof expected.rawValue === 'undefined' ||
typeof expected.weight === 'undefined') {
const msg =
`Config for ${name} is undefined or does not contain rawValue and weight properties`;
`aggregations: ${name} criteria does not contain expected rawValue or weight properties`;
throw new Error(msg);
}

if (typeof result === 'undefined' ||
typeof result.score === 'undefined') {
const msg =
`Audit result for ${name} is undefined or does not contain score property`;
let msg =
`${name} audit result is undefined or does not contain score property`;
if (result && result.debugString) {
msg += ': ' + result.debugString;
}
throw new Error(msg);
}

if (typeof result.score !== typeof expected.rawValue) {
const msg =
let msg =
`Expected rawValue of type ${typeof expected.rawValue}, got ${typeof result.rawValue}`;
if (result.debugString) {
msg += ': ' + result.debugString;
}
throw new Error(msg);
}

Expand Down

0 comments on commit ab96e71

Please sign in to comment.