egg-onerror icon indicating copy to clipboard operation
egg-onerror copied to clipboard

feat: allow customize isProd function

Open Jeff-Tian opened this issue 4 years ago • 4 comments

Checklist
  • [x] npm test passes
  • [x] tests and/or benchmarks are included
  • [x] documentation is changed or added
  • [x] commit message follows commit guidelines
Affected core subsystem(s)
Description of change

在碰到错误时,有一个判断是否为生产环境的逻辑 isProd,目前不能被自定义。故添加了自定义这个逻辑的功能,望采纳!

默认逻辑是看 app.config.env,如果不是 local 或者 unittest,就认为是正式生产环境,然而多数现实情况下,除了 local 和 unittest ,还有多个环境,比如:

  • dev
  • test
  • stage
  • prod
  • canary
  • qa 等等。很可能我们希望 dev 和 test 不算作正式环境(可以暴露原始错误堆栈信息)。

通过允许在 onerror 配置中自定义这个逻辑,可以让以上需求实现起来比较简单。

Jeff-Tian avatar Aug 13 '19 09:08 Jeff-Tian

Codecov Report

Merging #30 (c51746e) into master (55d27e6) will increase coverage by 0.05%. The diff coverage is 100.00%.

:exclamation: Current head c51746e differs from pull request most recent head 8958ad6. Consider uploading reports for the commit 8958ad6 to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
+ Coverage   96.98%   97.04%   +0.05%     
==========================================
  Files           5        5              
  Lines         166      169       +3     
==========================================
+ Hits          161      164       +3     
  Misses          5        5              
Impacted Files Coverage Δ
lib/utils.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 55d27e6...8958ad6. Read the comment docs.

codecov[bot] avatar Aug 13 '19 09:08 codecov[bot]

我们认为非本地环境都是在服务器部署的,行为应该一致,这个不应该被修改。

popomore avatar Aug 26 '19 10:08 popomore

默认是这样,但应允许改写,保持灵活

获取 Outlook for Androidhttps://aka.ms/ghei36


From: Haoliang Gao [email protected] Sent: Monday, August 26, 2019 6:25:02 PM To: eggjs/egg-onerror [email protected] Cc: Jeff [email protected]; Author [email protected] Subject: Re: [eggjs/egg-onerror] feat: allow customize isProd function (#30)

我们认为非本地环境都是在服务器部署的,行为应该一致,这个不应该被修改。

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/eggjs/egg-onerror/pull/30?email_source=notifications&email_token=AAZWHDDBR5VRDDSF2PZQLE3QGOVP5A5CNFSM4ILJBP5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5D67BI#issuecomment-524808069, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAZWHDDSWBPHA7Q5DDXBQQ3QGOVP5ANCNFSM4ILJBP5A.

Jeff-Tian avatar Aug 26 '19 12:08 Jeff-Tian

Duplicated with https://github.com/eggjs/egg-onerror/pull/33.

hyj1991 avatar Dec 10 '21 01:12 hyj1991