This commit is contained in:
Julien Valverdé
2024-07-15 02:22:40 +02:00
parent 63f636f231
commit 3ae5f31f96

View File

@@ -58,7 +58,7 @@ const mapErrors = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
Empty: cause => Effect.fail( Empty: cause => Effect.fail(
new TRPCError({ new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause), cause: new TRPCErrorCause(cause),
}) })
), ),
@@ -67,7 +67,7 @@ const mapErrors = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
? cause.error ? cause.error
: new TRPCError({ : new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause), cause: new TRPCErrorCause(cause),
}) })
), ),
@@ -76,35 +76,34 @@ const mapErrors = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
? cause.defect ? cause.defect
: new TRPCError({ : new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause), cause: new TRPCErrorCause(cause),
}) })
), ),
Interrupt: cause => Effect.fail( Interrupt: cause => Effect.fail(
new TRPCError({ new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause), cause: new TRPCErrorCause(cause),
}) })
), ),
Sequential: cause => Effect.fail( Sequential: cause => Effect.fail(
new TRPCError({ new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause), cause: new TRPCErrorCause(cause),
}) })
), ),
Parallel: cause => Effect.fail( Parallel: cause => Effect.fail(
new TRPCError({ new TRPCError({
code: "INTERNAL_SERVER_ERROR", code: "INTERNAL_SERVER_ERROR",
cause: new TRCPErrorCause(cause), cause: new TRPCErrorCause(cause),
}) })
), ),
}) })
) )
export class TRPCErrorCause<E> extends Error {
export class TRCPErrorCause<E> extends Error {
constructor(readonly cause: Cause.Cause<E>) { constructor(readonly cause: Cause.Cause<E>) {
super() super()
} }