-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
lib/application.js
Outdated
} catch (_) { | ||
// ignore, shouldjs will override error but missing setter. | ||
// https://github.com/shouldjs/should.js/blob/889e22ebf19a06bc2747d24cf34b25cc00b37464/lib/assertion-error.js#L26 | ||
} |
There was a problem hiding this comment.
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
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前担心这样会影响到 shouldjs 的错误输出排版。
不过也可以吧,我改改
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改了,@gxcsoccer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
覆盖一下 Object.defineProperty
?
另外加一个用例?
Codecov Report
@@ Coverage Diff @@
## master #3796 +/- ##
========================================
Coverage ? 100%
========================================
Files ? 34
Lines ? 943
Branches ? 0
========================================
Hits ? 943
Misses ? 0
Partials ? 0
Continue to review full report at Codecov.
|
1ab2047
to
ab63623
Compare
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const originMessage = err.message || '';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下面有个 if,不会进去。
@atian25 ci 没过 |
ab63623
to
09d2016
Compare
09d2016
to
cd8f24b
Compare
fix: error message rewrite when it has only a getter (#3796)
Checklist
npm test
passesAffected core subsystem(s)
Description of change