Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error management #160

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading