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

fix: error message rewrite when it has only a getter #3796

Merged
merged 2 commits into from
Jul 17, 2019

Conversation

atian25
Copy link
Member

@atian25 atian25 commented Jul 3, 2019

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

@atian25 atian25 requested review from fengmk2, gxcsoccer and killagu July 3, 2019 08:30
} catch (_) {
// ignore, shouldjs will override error but missing setter.
// https://github.com/shouldjs/should.js/blob/889e22ebf19a06bc2747d24cf34b25cc00b37464/lib/assertion-error.js#L26
}
Copy link
Contributor

@gxcsoccer gxcsoccer Jul 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const originMessage = err.message;

Object.defineProperty(this, "message", {
  get: function() {
    return originMessage + ' (uncaughtException throw ' + throwErrorCount + ' times on pid:' + process.pid + ')';
  },
  configurable: true,
  enumerable: false
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前担心这样会影响到 shouldjs 的错误输出排版。

不过也可以吧,我改改

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改了,@gxcsoccer

Copy link
Contributor

@gxcsoccer gxcsoccer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

覆盖一下 Object.defineProperty ?

另外加一个用例?

@codecov
Copy link

codecov bot commented Jul 4, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@489f52b). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #3796   +/-   ##
========================================
  Coverage          ?    100%           
========================================
  Files             ?      34           
  Lines             ?     943           
  Branches          ?       0           
========================================
  Hits              ?     943           
  Misses            ?       0           
  Partials          ?       0
Impacted Files Coverage Δ
lib/application.js 100% <ø> (ø)

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 489f52b...cd8f24b. Read the comment docs.

@atian25 atian25 force-pushed the compatibility-shouldjs branch from 1ab2047 to ab63623 Compare July 4, 2019 02:40
@@ -163,8 +163,17 @@ class Application extends EggApplication {
graceful({
server: [ server ],
error: (err, throwErrorCount) => {
if (err.message) {
err.message += ' (uncaughtException throw ' + throwErrorCount + ' times on pid:' + process.pid + ')';
const originMessage = err.message;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const originMessage = err.message || '';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面有个 if,不会进去。

@atian25 atian25 changed the title fix: ignore error message when it has only a getter fix: error message rewrite when it has only a getter Jul 11, 2019
@fengmk2
Copy link
Member

fengmk2 commented Jul 15, 2019

@atian25 ci 没过

@atian25 atian25 force-pushed the compatibility-shouldjs branch from ab63623 to 09d2016 Compare July 17, 2019 06:17
@atian25 atian25 requested a review from gxcsoccer July 17, 2019 07:08
@atian25 atian25 force-pushed the compatibility-shouldjs branch from 09d2016 to cd8f24b Compare July 17, 2019 07:11
@atian25 atian25 merged commit 6bfc0eb into master Jul 17, 2019
@atian25 atian25 deleted the compatibility-shouldjs branch July 17, 2019 10:02
popomore pushed a commit that referenced this pull request Jul 17, 2019
fix: error message rewrite when it has only a getter (#3796)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants