baptistemarchand / berror

Rich Errors including chain of causes, metadata, easy logging and TypeScript definitions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ie11 support

roopakv opened this issue · comments

Seems like this breaks on ie11. I haven't yet narrowed down exactly what. Would love some help if you might know what is up

Hi @roopakv,
Thanks for the bug report!
The tsconfig targets es6 which is not supported by ie11 I think.
I’ll have a look soon

Yay thank you! And I'm assuming that's the case but I'm not a100% sure

@roopakv I published a new version. Could you please let me know if it works in ie11 now?

I'll give it a shot later this week, and let you know. Thank you for being so responsive and on top of this.

1.0.9 seems working fine on IE, however es5 brought another minor issue.

We have code like this

// custom error class
export class FooError extends BError {
  constructor(public readonly message) { super(message) }
}

// test
expect(foo()).is.instanceOf(FooError);

instanceof is broken in this case as described in https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work

we can use workaround described in above link (using setPrototypeOf) so it's not big deal but I thought I'd just let you know for your information

actually I think above means BError class should also have Object.setPrototypeOf(this, BError.prototype); in constructor if it targets es5

Thanks for all the info @daisy1754 ! That's very helpful.
I'll add a fix and a test for that very soon.

I published a new version that includes this fix. Thank you for the help!

@daisy1754 @roopakv while I have you here, would you mind telling me how you found this repo? I didn't really expect anyone to use it because I didn't do any communication around it, so that was a nice surprise.

Hey Baptiste, I was looking for a error handling package that does not need node as a dependency to reduce our bundle size.

I noticed you have no deps which is a blessing.

Found you on npmjs by searching for error verror etc.