Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed tiny problem in assert - it was throwing errors for me until this fix #167

Closed
wants to merge 3 commits into from

3 participants

Brady Wetherington Maciej Małecki Charlie Robbins
Brady Wetherington

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.

uberbrady added some commits
Brady Wetherington uberbrady 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.
7be2bcf
Brady Wetherington uberbrady tab to space fix, sorry! f937e91
Brady Wetherington uberbrady Stupid tabs. 296c07a
Maciej Małecki

I'm curious, what errors was it throwing?

Charlie Robbins
Owner

Closing for lack of follow-up.

Charlie Robbins indexzero closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2011
  1. Brady Wetherington

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

    uberbrady authored
    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.
  2. Brady Wetherington

    tab to space fix, sorry!

    uberbrady authored
  3. Brady Wetherington

    Stupid tabs.

    uberbrady authored
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/assert/error.js
12 lib/assert/error.js
View
@@ -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) {
Something went wrong with that request. Please try again.