-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cross-frame compatible Error checking for fail
- Loading branch information
1 parent
44b0045
commit 3fcca2e
Showing
2 changed files
with
11 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,7 +202,7 @@ Runner.prototype.fail = function(test, err) { | |
++this.failures; | ||
test.state = 'failed'; | ||
|
||
if (!(err instanceof Error)) { | ||
if (!(err instanceof Error || err && typeof err.message == 'string')) { | ||
err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)'); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
outdooricon
Author
Contributor
|
||
} | ||
|
||
|
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
drop the original stacktrace? why? you should inform the developer about the original error, not just funny(?) message. for example:
err = new Error('the ' + type(err) + ' ' + stringify(err) + ' (' + err.stack.substring(0, err.stack.indexOf("\n", err.stack.indexOf("\n") + 1)) + ') ' + ' was thrown, throw an Error :)');
a little part of original stacktrace instead of "the error {} was thrown, throw an Error :)" meaningless funny message.
under nodejs