Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

If message is not a string this doesn't work.

On the assertion side - when things are going wrong we can't assume that the 'message' will be a valid string. It might not be. Or might not be defined. Either way, as opposed to throwing errors at 'assert', we should at least allow whatever message we do have to be displayed.
  • Loading branch information...
commit 7be2bcfd4d21c1b53f8b722cf27881b7eb2652aa 1 parent 08b0650
@uberbrady authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/assert/error.js
View
12 lib/assert/error.js
@@ -19,10 +19,14 @@ require('assert').AssertionError.prototype.toString = function () {
else {
expected = inspect(that.expected, {showHidden: that.actual instanceof Error});
}
-
- return str.replace(/{actual}/g, actual).
- replace(/{operator}/g, stylize(that.operator, 'bold')).
- replace(/{expected}/g, expected);
+ try {
+ return str.replace(/{actual}/g, actual).
+ replace(/{operator}/g, stylize(that.operator, 'bold')).
+ replace(/{expected}/g, expected);
+ }
+ catch(e) {
+ return str;
+ }
}
if (this.message) {
Please sign in to comment.
Something went wrong with that request. Please try again.