not working on iojs
Closed this issue · 6 comments
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)
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);
Thank you. No, that code work perfectly even with iojs. I'll try to extract some code that reproduce my problem
Great!
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
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
Sorry for the delay. I'm fixing this now.