feat: 报错页面增加一个快速生成 issue 的按钮 (#5141)

This commit is contained in:
Henry Wang 2020-07-07 10:41:10 +01:00 committed by GitHub
parent 065ddbfd07
commit 7475bcacfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 88 additions and 18 deletions

View File

@ -4,21 +4,22 @@ about: Submit discovered bugs
---
<!--
Please ensure you have read [documentation](https://docs.rsshub.app/en), and provide all the information required by this template.
Otherwise the issue will be closed immediately.
Due to the anti-crawling of the source website, some RSS of the demo will return status code 403. Please do not repeat the issue.
Please ensure you have read [documentation](https://docs.rsshub.app/en), and provide all the information required by this template, otherwise the issue will be closed immediately.
Due to the anti-crawling of the certain source website, some RSS of the demo will return status code 403. This is not an issue caused by RSSHub and please do not report it.
-->
### Involved route
- Involved route
### What is expected?
- What is expected
### What is actually happening?
- What is actually happening
### Self-deployed information
- Self-deployment information
<!--
Delete this section if you are using [RSSHub demo](https://rsshub.app).
Please ensure you have deployed the [master branch](https://github.com/DIYgod/RSSHub/tree/master) of RSSHub.
-->
@ -28,4 +29,4 @@ Please ensure you have deployed the [master branch](https://github.com/DIYgod/RS
| Node version | |
| if Docker, version | |
### Additional info (logs errors etc)
- Additional info (logs errors etc)

View File

@ -4,22 +4,23 @@ about: 早起的小可爱有虫抓
---
<!--
请确保已阅读 [文档](https://docs.rsshub.app) 内相关部分,并按照模版提供信息
否则 issue 将被立即关闭
由于源网站反爬缘故演示地址一些rss会返回status code 403请勿重复提issue
请确保已阅读 [文档](https://docs.rsshub.app) 内相关部分,并按照模版提供信息,否则 issue 将被立即关闭。
由于部分源网站反爬缘故,演示地址一些 rss 会返回 status code 403该问题不是 RSSHub 所致,请勿提issue
-->
### 路由地址
- 路由地址
### 预期是什么?
- 预期是什么
### 实际发生了什么?
- 实际发生了什么
### 部署相关信息
- 部署相关信息
<!--
如果是演示地址(rsshub.app)有此问题请删除此部分
请确保您部署的是[主线 master 分支](https://github.com/DIYgod/RSSHub/tree/master)最新版 RSSHub
如果是演示地址(rsshub.app)有此问题请删除此部分。
请确保您部署的是[主线 master 分支](https://github.com/DIYgod/RSSHub/tree/master)最新版 RSSHub。
-->
| Env | Value |
@ -28,4 +29,4 @@ about: 早起的小可爱有虫抓
| Node version | |
| if Docker, version | |
### 额外信息(日志、报错等)
- 额外信息(日志、报错等)

View File

@ -22,6 +22,74 @@ module.exports = async (ctx, next) => {
let message = err;
if (err.name && (err.name === 'HTTPError' || err.name === 'RequestError')) {
message = `${err.message}: target website might be blocking our access, you can <a href="https://docs.rsshub.app/install/">host your own RSSHub instance</a> for a better usability.`;
const templateZh = `<!--
请确保已阅读 [文档](https://docs.rsshub.app) 内相关部分,并按照模版提供信息,否则 issue 将被立即关闭。
由于部分源网站反爬缘故演示地址一些 rss 会返回 status code 403该问题不是 RSSHub 所致请勿提交 issue
-->
- 路由地址
\`${ctx.path}\`
- 预期是什么
- 实际发生了什么
- 部署相关信息
<!--
如果是演示地址(rsshub.app)有此问题请删除此部分
请确保您部署的是[主线 master 分支](https://github.com/DIYgod/RSSHub/tree/master)最新版 RSSHub。
-->
| Env | Value |
| ------------------ | ------------- |
| OS | |
| Node version |${process.version} |
| if Docker, version | |
- 额外信息日志报错等
\`\`\`
${err.message}
\`\`\` `;
const templateEn = `<!--
Please ensure you have read [documentation](https://docs.rsshub.app/en), and provide all the information required by this template, otherwise the issue will be closed immediately.
Due to the anti-crawling of the certain source website, some RSS of the demo will return status code 403. This is not an issue caused by RSSHub and please do not report it.
-->
- Involved route
\`${ctx.path}\`
- What is expected
- What is actually happening
- Self-deployment information
<!--
Delete this section if you are using [RSSHub demo](https://rsshub.app).
Please ensure you have deployed the [master branch](https://github.com/DIYgod/RSSHub/tree/master) of RSSHub.
-->
| Env | Value |
| ------------------ | ------------- |
| OS | |
| Node version |${process.version} |
| if Docker, version | |
- Additional info (logs errors etc)
\`\`\`
${err.message}
\`\`\` `;
message += `<br><br>如果您认为 RSSHub 导致了该错误,<a href="https://github.com/DIYgod/RSSHub/issues/new?template=bug_report_zh.md&title=[BUG]&body=${encodeURI(templateZh)}" target="_blank">请在 GitHub 报告</a>。`;
message += `<br><br>If you believe this is an error caused by RSSHub, please <a href="https://github.com/DIYgod/RSSHub/issues/new?template=bug_report_en.md&title=[BUG]&body=${encodeURI(
templateEn
)}" target="_blank">report me on GitHub</a>.`;
} else if (err instanceof Error) {
message = err.stack;
}