From e6d86620531c7a6f664db6b38099e7bb3172877f Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Fri, 13 Dec 2024 12:39:40 +0100 Subject: [PATCH] Improve error management (#160) Closes #71 --- lib/views/error.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/views/error.js b/lib/views/error.js index b5294e2..0c4f852 100644 --- a/lib/views/error.js +++ b/lib/views/error.js @@ -52,10 +52,24 @@ ${stack} \`\`\`` : ""; } + fileIssue(err, pr) { + let service = err.data && err.data.service; + if (service) { + let name = service.name; + let link = `[${name}](${service.url})`; + return ```_This seems to be an issue with the ${ link } service. PR Preview doesn't manage this service and so has no control over it. If you've identified an issue with it, you can [report the issue to the maintainers of ${ name }](${ service.reportIssue }) directly. Please be courteous. Thank you!_ + +_If you don't have enough information above to solve the error by yourself or if the issue doesn't seem related to ${ name }, you can [file an issue with PR Preview](${ this.issueUrl(pr) })._``` + } else { + return `_If you don't have enough information above to solve the error by yourself, please [file an issue](${ this.issueUrl(pr) })._`; + } + } + summary(err, pr) { let service = this.service(err); let link = this.link(err); let stack = this.stack(err); + let fileIssue = this.fileIssue(err); //if (!stack && !link) { return ""; } //if (!stack) { return link; } return `
@@ -67,14 +81,15 @@ ${ link } ${ stack } -_If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please [file an issue](${ this.issueUrl(pr) })._ +${ fileIssue } +
`; } issueUrl(pr) { var base = "https://github.com/tobie/pr-preview/issues/new"; - return `${base}?title=Error%20not%20surfaced%20properly&body=See%20${pr.owner}/${pr.repo}%23${pr.number}.`; + return `${base}?title=Unidentified%20Error&body=See%20${pr.owner}/${pr.repo}%23${pr.number}.`; } } -module.exports = ViewError; \ No newline at end of file +module.exports = ViewError;