sindresorhus/serialize-error

Optionally preserve current stack

Fechada

#98 aberto em 25 de set. de 2024

 (6 comentários) (0 reação) (0 responsável)JavaScript (69 forks)user submission
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:

So how about:

throw deserializeError(serialized, {preserveStack: true});

Guia do colaborador