String error property is set, making error in third party module #2

zazabe opened this Issue Mar 19, 2013 · 1 comment

2 participants


String object has a strange behavior when rconsole is present:

$ node
> "toto".error
> require('rconsole')
> "toto".error

I'm using a module making a test on parsed error property, this module is broken because of this strange issue...

consider an API (Mailchimp in some cases) with response like that :

  • failed: {"error":"error message"}
  • successful: "value"
var data = JSON.parse(response);
// failed : data.error = "\u001b[31value\u001b[39m"
// successful : data.error = "error message"

if(data.error){...} //always true

I think the problem is to use, with String.prototype extension, but i suspect rconsole to do the same by setting error property on objects.

Is it smell not good or I miss something ?


+1, I've also been bitten by this. I had a variable which either referred to a string or an object with an 'error' property. I was unable to simply check that thing.error was non-false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment