Files
SnowLuma/.pnpm-store/v11/files/8c/92cc2b1d2ffb92c7cfeaf34108c14fca1b080caba298b380659486fbe1038e4af5527d9a175eec728a3437b6d40b8092f4855109100504391a6ae420d8e0b7
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

32 lines
908 B
Plaintext

//#region src/ssr/serializer/ShallowErrorPlugin.ts
/**
* this plugin serializes only the `message` part of an Error
* this helps with serializing e.g. a ZodError which has functions attached that cannot be serialized
*/
const ShallowErrorPlugin = /* @__PURE__ */ (0, require("seroval").createPlugin)({
tag: "$TSR/Error",
test(value) {
return value instanceof Error;
},
parse: {
sync(value, ctx) {
return { message: ctx.parse(value.message) };
},
async async(value, ctx) {
return { message: await ctx.parse(value.message) };
},
stream(value, ctx) {
return { message: ctx.parse(value.message) };
}
},
serialize(node, ctx) {
return "new Error(" + ctx.serialize(node.message) + ")";
},
deserialize(node, ctx) {
return new Error(ctx.deserialize(node.message));
}
});
//#endregion
exports.ShallowErrorPlugin = ShallowErrorPlugin;
//# sourceMappingURL=ShallowErrorPlugin.cjs.map