eris icon indicating copy to clipboard operation
eris copied to clipboard

fix(getMessages): Emit Error object in "error" event

Open frobinsonj opened this issue 2 years ago • 4 comments

Didn't really know how to title this, apologies if I got it wrong.

Error event err param should be type Error - https://github.com/abalabahaha/eris/blob/dev/index.d.ts#L711

frobinsonj avatar Jun 16 '22 17:06 frobinsonj

It would probably be better to construct the error object, then overwrite the stack Or even just override the message of the caught error then emit it rather than both making a new error object & emitting the original stack

DonovanDMC avatar Jun 17 '22 00:06 DonovanDMC

options.cause was added in node 16.9.0, we're currently on v10 (v14 at the latest), so we cannot use it

Went with your original suggestion. Thanks.

frobinsonj avatar Jun 18 '22 15:06 frobinsonj

We can slice the first line off the stack and remake it with the new message

or we can just ignore the original stack and construct a new error

DonovanDMC avatar Jun 18 '22 22:06 DonovanDMC

Any other alternatives to this? Current solution (although error might be hard to read) is the best one imo

bsian03 avatar Jan 05 '24 14:01 bsian03