TRCPErrorCause

This commit is contained in:
Julien Valverdé
2024-07-14 07:47:54 +02:00
parent c001738f46
commit 5a3400f6dd

View File

@@ -56,22 +56,52 @@ const mapErrors = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
Effect.sandbox(effect).pipe(
Effect.catchTags({
Die: cause => Effect.fail(
new TRPCError({ code: "INTERNAL_SERVER_ERROR", cause })
new TRPCError({
code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause),
})
),
Interrupt: cause => Effect.fail(
new TRPCError({ code: "INTERNAL_SERVER_ERROR", cause })
new TRPCError({
code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause),
})
),
Fail: cause => Effect.fail(
new TRPCError({ code: "INTERNAL_SERVER_ERROR", cause })
new TRPCError({
code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause),
})
),
Empty: cause => Effect.fail(
new TRPCError({ code: "INTERNAL_SERVER_ERROR", cause })
new TRPCError({
code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause),
})
),
Parallel: cause => Effect.fail(
new TRPCError({ code: "INTERNAL_SERVER_ERROR", cause })
new TRPCError({
code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause),
})
),
Sequential: cause => Effect.fail(
new TRPCError({ code: "INTERNAL_SERVER_ERROR", cause })
new TRPCError({
code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause),
})
),
})
)
export class TRCPErrorCause extends Error {
constructor(readonly cause: unknown) {
super()
}
}