This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
assert: manutally create stack trace message #5123
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v8 has changed how it generates it's messages, so as a fix the stack is manually manipulated after to properly display the assert message text.
hold off. found a better way. going to amend |
nope. not going to spend more time on this. |
What about something like this? diff --git a/lib/assert.js b/lib/assert.js
index a2afdcf..d19b163 100644
--- a/lib/assert.js
+++ b/lib/assert.js
@@ -45,9 +45,9 @@ assert.AssertionError = function AssertionError(options) {
this.operator = options.operator;
var stackStartFunction = options.stackStartFunction || fail;
- if (Error.captureStackTrace) {
- Error.captureStackTrace(this, stackStartFunction);
- }
+ this.name = this.toString();
+ this.toString = Error.prototype.toString;
+ Error.captureStackTrace(this, stackStartFunction);
};
// assert.AssertionError instanceof Error
|
You'll have to revert the DEBUG message manipulation I did in fs.js. For But nice solution. Had tried something similar with setting the message |
Fixed on 4716dc6 |
richardlau
pushed a commit
to ibmruntimes/node
that referenced
this pull request
Feb 29, 2016
* buffer: - You can now supply an encoding argument when filling a Buffer Buffer#fill(string[, start[, end]][, encoding]), supplying an existing Buffer will also work with Buffer#fill(buffer[, start[, end]]). See the API documentation for details on how this works. (Trevor Norris) nodejs#4935 - Buffer#indexOf() no longer requires a byteOffset argument if you also wish to specify an encoding: Buffer#indexOf(val[, byteOffset][, encoding]). (Trevor Norris) nodejs#4803 * child_process: spawn() and spawnSync() now support a 'shell' option to allow for optional execution of the given command inside a shell. If set to true, cmd.exe will be used on Windows and /bin/sh elsewhere. A path to a custom shell can also be passed to override these defaults. On Windows, this option allows .bat. and .cmd files to be executed with spawn() and spawnSync(). (Colin Ihrig) nodejs#4598 * http_parser: Update to http-parser 2.6.2 to fix an unintentionally strict limitation of allowable header characters. (James M Snell) nodejs#5237 * dgram: socket.send() now supports accepts an array of Buffers or Strings as the first argument. See the API docs for details on how this works. (Matteo Collina) nodejs#4374 * http: Fix a bug where handling headers will mistakenly trigger an 'upgrade' event where the server is just advertising its protocols. This bug can prevent HTTP clients from communicating with HTTP/2 enabled servers. (Fedor Indutny) nodejs#4337 * net: Added a listening Boolean property to net and http servers to indicate whether the server is listening for connections. (José Moreira) nodejs#4743 * node: The C++ node::MakeCallback() API is now reentrant and calling it from inside another MakeCallback() call no longer causes the nextTick queue or Promises microtask queue to be processed out of order. (Trevor Norris) nodejs#4507 * tls: Add a new tlsSocket.getProtocol() method to get the negotiated TLS protocol version of the current connection. (Brian White) nodejs#4995 * vm: Introduce new 'produceCachedData' and 'cachedData' options to new vm.Script() to interact with V8's code cache. When a new vm.Script object is created with the 'produceCachedData' set to true a Buffer with V8's code cache data will be produced and stored in cachedData property of the returned object. This data in turn may be supplied back to another vm.Script() object with a 'cachedData' option if the supplied source is the same. Successfully executing a script from cached data can speed up instantiation time. See the API docs for details. (Fedor Indutny) nodejs#4777 * performance: Improvements in: - process.nextTick() (Ruben Bridgewater) nodejs#5092 - path module (Brian White) nodejs#5123 - querystring module (Brian White) nodejs#5012 - streams module when processing small chunks (Matteo Collina) nodejs#4354 PR-URL: nodejs/node#5295
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
v8 has changed how it generates it's messages, so as a fix the stack is
manually manipulated after to properly display the assert message text.
This change is absolute crap, and I don't like manipulating the stack trace string this way. But so far it's the only way I've figured out how to do it. Will look for a better way for a little longer, but go ahead and use this if you want.