From 7475bcacfb57c12a2e9c30ac5b34cfd9708942b9 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Tue, 7 Jul 2020 10:41:10 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8A=A5=E9=94=99=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=BF=AB=E9=80=9F=E7=94=9F?= =?UTF-8?q?=E6=88=90=20issue=20=E7=9A=84=E6=8C=89=E9=92=AE=20(#5141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug_report_en.md | 17 ++++--- .github/ISSUE_TEMPLATE/bug_report_zh.md | 21 ++++---- lib/middleware/onerror.js | 68 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 18 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report_en.md b/.github/ISSUE_TEMPLATE/bug_report_en.md index 7d40bd58d..3e0db32e2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_en.md +++ b/.github/ISSUE_TEMPLATE/bug_report_en.md @@ -4,21 +4,22 @@ about: Submit discovered bugs --- -### Involved route +- Involved route -### What is expected? +- What is expected -### What is actually happening? +- What is actually happening -### Self-deployed information +- Self-deployment information @@ -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) diff --git a/.github/ISSUE_TEMPLATE/bug_report_zh.md b/.github/ISSUE_TEMPLATE/bug_report_zh.md index 942541d6e..9966c0c2b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_zh.md +++ b/.github/ISSUE_TEMPLATE/bug_report_zh.md @@ -4,22 +4,23 @@ about: 早起的小可爱有虫抓 --- -### 路由地址 +- 路由地址 -### 预期是什么? +- 预期是什么 -### 实际发生了什么? +- 实际发生了什么 -### 部署相关信息 +- 部署相关信息 | Env | Value | @@ -28,4 +29,4 @@ about: 早起的小可爱有虫抓 | Node version | | | if Docker, version | | -### 额外信息(日志、报错等) +- 额外信息(日志、报错等) diff --git a/lib/middleware/onerror.js b/lib/middleware/onerror.js index 161a7c331..2c6cf39c8 100644 --- a/lib/middleware/onerror.js +++ b/lib/middleware/onerror.js @@ -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 host your own RSSHub instance for a better usability.`; + + const templateZh = ` + +- 路由地址 + \`${ctx.path}\` +- 预期是什么 + +- 实际发生了什么 + +- 部署相关信息 + + + +| Env | Value | +| ------------------ | ------------- | +| OS | | +| Node version |${process.version} | +| if Docker, version | | + +- 额外信息(日志、报错等) +\`\`\` + ${err.message} +\`\`\` `; + + const templateEn = ` + +- Involved route + \`${ctx.path}\` +- What is expected + +- What is actually happening + +- Self-deployment information + + + +| Env | Value | +| ------------------ | ------------- | +| OS | | +| Node version |${process.version} | +| if Docker, version | | + +- Additional info (logs errors etc) +\`\`\` + ${err.message} +\`\`\` `; + + message += `

如果您认为 RSSHub 导致了该错误,请在 GitHub 报告。`; + + message += `

If you believe this is an error caused by RSSHub, please report me on GitHub.`; } else if (err instanceof Error) { message = err.stack; }