sindresorhus/serialize-error

Optionally preserve current stack

Open

#98 opened on 2024年9月25日

GitHub で見る
 (6 comments) (0 reactions) (0 assignees)JavaScript (599 stars) (69 forks)user submission
enhancementhelp wanted

説明

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

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

Optionally preserve current stack · sindresorhus/serialize-error#98 | Good First Issue