sindresorhus/serialize-error

Optionally preserve current stack

Open

#98 创建于 2024年9月25日

在 GitHub 查看
 (6 评论) (0 反应) (0 负责人)JavaScript (599 star) (69 fork)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