sindresorhus/serialize-error

Optionally preserve current stack

クローズ

#98 opened on 2024/09/25

 (6 件のコメント) (0 件のリアクション) (0 人の担当者)JavaScript (69 件のフォーク)user submission
enhancementhelp wanted

Repository metrics

Stars
 (599 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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

コントリビューターガイド