sindresorhus/serialize-error

Optionally preserve current stack

已关闭

#98 创建于 2024年9月25日

 (6 条评论) (0 个反应) (0 位负责人)JavaScript (69 个派生)user submission
enhancementhelp wanted

仓库指标

星标
 (599 个星标)
PR 合并指标
 (30 天内没有已合并 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});

贡献者指南