AriaMinaei / pretty-error

See node.js errors with less clutter
MIT License
1.52k stars 48 forks source link

not working on iojs #14

Closed parroit closed 9 years ago

parroit commented 9 years ago

I'm getting a console warning when requiring the module:

sys is deprecated. Use util instead.

and when try to prettify an error, I got this exception:

/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/SpecialString.js:18
    if (this.constructor !== self) {
            ^
TypeError: Cannot read property 'constructor' of undefined
    at SpecialString (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/SpecialString.js:16:13)
    at Block.module.exports.Block._writeInline (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:196:9)
    at Block.module.exports.Block._flushBuffer (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:165:10)
    at Block.module.exports.Block._deactivate (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:93:10)
    at Block.module.exports.Block._activate (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:82:22)
    at Block.module.exports.Block._open (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:123:10)
    at Block.module.exports.Block.openBlock (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:154:11)
    at RenderKid.module.exports.RenderKid._renderBlockNode (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/RenderKid.js:149:25)
    at RenderKid.module.exports.RenderKid._renderNode (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/RenderKid.js:124:12)
    at RenderKid.module.exports.RenderKid._renderChildrenOf (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/RenderKid.js:114:12)
AriaMinaei commented 9 years ago

I fixed the deprecation warning, but I can't seem to reproduce the exception. Does this code throw the same error?

var PrettyError = require('pretty-error');
var pe = new PrettyError();
var renderedError = pe.render(new Error('Some error message'));

console.log(renderedError);
parroit commented 9 years ago

Thank you. No, that code work perfectly even with iojs. I'll try to extract some code that reproduce my problem

AriaMinaei commented 9 years ago

Great!

parroit commented 9 years ago

The error appear because I'm using babel, with the options ignore:true. This way, my node_modules are babelified too, and it appear that this is causing the exception. If I remove the options, all it's working

parroit commented 9 years ago

It look that SpecialString string has a strange way to check if it's called as a function:

function SpecialString(str) {
    if (this.constructor !== self) {
      return new self(str);
    }
    this._str = String(str);
    this._len = 0;
  }

If I replace with a more idiomatic

function SpecialString(str) {
    if (! (this instanceof self) ) {
      return new self(str);
    }
    this._str = String(str);
    this._len = 0;
  }

then it work even if is babelified. Do you think I should post an issue to babel or to renderkid? In the meanwhile I close this because it doesn't appear to be a problem of pretty-errror

AriaMinaei commented 9 years ago

Sorry for the delay. I'm fixing this now.