Handle errors that do not belong to a URL. (#2772)
This commit is contained in:
parent
1a98d1307c
commit
50433de063
|
|
@ -12,6 +12,7 @@ class DataCollector {
|
|||
this.urlPages = {};
|
||||
this.summaryPages = {};
|
||||
this.browsertimeScreenshots = false;
|
||||
this.errors = {};
|
||||
}
|
||||
|
||||
_addUrl(url) {
|
||||
|
|
@ -66,6 +67,18 @@ class DataCollector {
|
|||
);
|
||||
}
|
||||
|
||||
getErrors() {
|
||||
return this.errors;
|
||||
}
|
||||
|
||||
addError(source, data) {
|
||||
if (this.errors[source]) {
|
||||
this.errors[source].push(data);
|
||||
} else {
|
||||
this.errors[source] = [data];
|
||||
}
|
||||
}
|
||||
|
||||
addErrorForUrl(url, source, data) {
|
||||
this._addUrl(url);
|
||||
const errors = get(this.urlPages[url], 'errors', {});
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ class HTMLBuilder {
|
|||
const nTestedPages = dataCollector.getURLs().length;
|
||||
log.debug('Render HTML for %s page(s) ', nTestedPages);
|
||||
const errors = dataCollector.getErrorUrls();
|
||||
// If we have any errors that are not linked to a URL, add them
|
||||
if (Object.keys(dataCollector.getErrors()).length > 0) {
|
||||
errors['generic'] = dataCollector.getErrors();
|
||||
}
|
||||
const css = this.inlineCSS.join('');
|
||||
const assetsBaseURL = this.options.html.assetsBaseURL;
|
||||
if (Object.keys(errors).length > 0) {
|
||||
|
|
|
|||
|
|
@ -106,11 +106,15 @@ module.exports = {
|
|||
} else {
|
||||
switch (message.type) {
|
||||
case 'error': {
|
||||
dataCollector.addErrorForUrl(
|
||||
message.url,
|
||||
message.source,
|
||||
message.data
|
||||
);
|
||||
if (message.url) {
|
||||
dataCollector.addErrorForUrl(
|
||||
message.url,
|
||||
message.source,
|
||||
message.data
|
||||
);
|
||||
} else {
|
||||
dataCollector.addError(message.source, message.data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// we always want to add data from our HARs
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ mixin row(errors)
|
|||
each error, url in errors
|
||||
tr
|
||||
td
|
||||
a(href=url)= url
|
||||
- if (url !== 'generic')
|
||||
a(href=url)= url
|
||||
td
|
||||
ul
|
||||
each pageerrors, tool in error
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class DataCollector {
|
|||
this.resultUrls = context.resultUrls;
|
||||
this.urlRunPages = {};
|
||||
this.urlPages = {};
|
||||
this.errors = {};
|
||||
this.summaryPage = {};
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +35,18 @@ class DataCollector {
|
|||
return this.urlPages[url];
|
||||
}
|
||||
|
||||
getErrors() {
|
||||
return this.errors;
|
||||
}
|
||||
|
||||
addError(source, data) {
|
||||
if (this.errors[source]) {
|
||||
this.errors[source].push(data);
|
||||
} else {
|
||||
this.errors[source] = [data];
|
||||
}
|
||||
}
|
||||
|
||||
addErrorForUrl(url, source, data) {
|
||||
this._addUrl(url);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ function send(options, dataCollector, context, screenshotType) {
|
|||
|
||||
for (const url of dataCollector.getURLs()) {
|
||||
const errors = dataCollector.getURLData(url).errors;
|
||||
|
||||
if (errors) {
|
||||
pageErrors.push(errors);
|
||||
}
|
||||
|
|
@ -98,7 +99,15 @@ module.exports = {
|
|||
|
||||
switch (message.type) {
|
||||
case 'error': {
|
||||
dataCollector.addErrorForUrl(message.url, message.source, message.data);
|
||||
if (message.url) {
|
||||
dataCollector.addErrorForUrl(
|
||||
message.url,
|
||||
message.source,
|
||||
message.data
|
||||
);
|
||||
} else {
|
||||
dataCollector.addError(message.source, message.data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue