sindresorhus/serialize-error

Optionally preserve current stack

Geschlossen

#98 geöffnet am 25.09.2024

 (6 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (69 Forks)user submission
enhancementhelp wanted

Repository-Metriken

Stars
 (599 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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});

Contributor Guide