TRCPErrorCause
This commit is contained in:
@@ -56,22 +56,52 @@ const mapErrors = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
|
|||||||
Effect.sandbox(effect).pipe(
|
Effect.sandbox(effect).pipe(
|
||||||
Effect.catchTags({
|
Effect.catchTags({
|
||||||
Die: cause => Effect.fail(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user