Skip to content

Commit

Permalink
Improve error management (#160)
Browse files Browse the repository at this point in the history
Closes #71
  • Loading branch information
tobie authored Dec 13, 2024
1 parent 4e7fe76 commit e6d8662
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/views/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<details>
Expand All @@ -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 }
</details>`;
}

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;
module.exports = ViewError;

0 comments on commit e6d8662

Please sign in to comment.