sindresorhus/serialize-error
Optionally preserve current stack
Fechada
#98 aberto em 25 de set. de 2024
enhancementhelp wanted
Métricas do repositório
- Stars
- (599 estrelas)
- Métricas de merge de PR
- (Nenhuma PRs mesclada em 30d)
Description
An issue I found when throwing deserialized errors is that the thrown error has no reference to this throw point.
I think the "correct" way to throw serialized errors would be something like:
throw new Error(serialized.message, {
cause: deserializeError(serialized),
});
Two drawbacks:
new Errordoesn't benefit from https://github.com/sindresorhus/serialize-error/pull/70- this isn't necessarily what people want or expect by default
So how about:
throw deserializeError(serialized, {preserveStack: true});