| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
The message will not change, but the stack trace will 🤔 |
Sorry, something went wrong.
|
It might be the smallest semver-major ever, but I would still say semver-major. Imagine the impact on someone reading the stack traces if they run the same test on different versions of Node.js (which is what someone might do if they suspect they are triggering a bug in Node.js itself). If assert.ifError() returns a different stack trace in the same exact situation between Node.js 7.10.0 and Node.js 8.0.0, well, that's what happens between major versions. But different results between Node.js 7.10.0 and 7.11.0? I'd be less understanding about that... |
Sorry, something went wrong.
|
Is this a good idea, though? I think I would usually be more interested in the original stack trace (and apart from that, I think that this won’t work if somebody accessed err.stack before ifError() is called) to figure out why there was an error |
Sorry, something went wrong.
There was a problem hiding this comment.
We should add a test for this..
Sorry, something went wrong.
|
I'm not sure this is a good change to make. The errors are created elsewhere and passed here. Changing the stack trace would definitely be a breaking change (even if a mild one). I don't think this is behavior anyone would expect. |
Sorry, something went wrong.
One could argue that if you want the original stack, just throw it. If you use assert, you want to knwo which asset failed... c:\code\node$ node --no-deprecation test/parallel/test-fs-chmod.js
33060
assert.js:378
assert.ifError = function ifError(err) { if (err) throw err; };
^
Error: EPERM: operation not permitted, open 'd:\code\node\test\fixtures\a1.js'
|
Sorry, something went wrong.
|
I think we should either throw the existing error, as is, or throw a new assertion error. This hybrid seems confusing. |
Sorry, something went wrong.
Bingo! |
Sorry, something went wrong.
|
Changed to wrapping the original err in a new AssertionError (per @cjihrig's comment). |
Sorry, something went wrong.
|
Wrapping in the AssertionError works. We will definitely want to run some CITGM tests on this tho |
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
message isn't used.
Sorry, something went wrong.
There was a problem hiding this comment.
Ack.
Forgot to carry it over into the last commit.
Sorry, something went wrong.
Sorry, something went wrong.
|
CI: https://ci.nodejs.org/job/node-test-commit/10191/ |
Sorry, something went wrong.
|
Ping @nodejs/testing |
Sorry, something went wrong.
|
I now kinda hate the current ifError. Re: 1307 parallel/test-util-callbackify
duration_ms 0.89
severity fail
stack ->
assert.js:586
assert.ifError = function ifError(err) { if (err) throw err; };
^
function () {
context.actual++;
return fn.apply(this, arguments);
} |
Sorry, something went wrong.
|
|
||
| Throws an `AssertionError` if `value` is truthy. This is useful when testing the | ||
| `error` argument in callbacks. If the `message` parameter is undefined, a | ||
| default error message is assigned, and `value` is be appended to it. |
There was a problem hiding this comment.
I feel this is somewhat contradicting each other. If it should be used in callbacks, there should always either be an error or the result but never both at the same time.
Sorry, something went wrong.
| common.expectsError({ | ||
| code: 'ERR_ASSERTION', | ||
| type: a.AssertionError, | ||
| message: /^Error: test_error_slug$/m |
There was a problem hiding this comment.
I am not sure how this is any different from the test above. I actually would expect this test to fail because I would have expected it to be wrapped in the ifError failed part.
Sorry, something went wrong.
| assert.ifError = function ifError(err) { if (err) throw err; }; | ||
| assert.ifError = function ifError(err, message) { | ||
| if (!err) return; | ||
| message = message || `ifError failed. Original error:\n${err}`; |
There was a problem hiding this comment.
Hm, is ifError really failing here? Maybe smth. like ifError encountered unexpected error: ... might be more intuitive?
Sorry, something went wrong.
|
I am closing this due to the long inactivity. @refack please reopen if you would like to pursue this further. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
For assert.ifError fails, wrap the original err in a new AssertionError
Inspiration: #12803 (comment)
/cc @nodejs/testing
Checklist
Affected core subsystem(s)
test, assert