QueryErrorHandler work
All checks were successful
Lint / lint (push) Successful in 16s

This commit is contained in:
Julien Valverdé
2025-03-15 02:30:37 +01:00
parent 5614b8df38
commit 0437fa5dcc
4 changed files with 35 additions and 7 deletions

View File

@@ -0,0 +1,26 @@
import { HttpClientError } from "@effect/platform"
import { ErrorHandler } from "@reffuse/extension-query"
import { Cause, Chunk, Effect, flow, Match, Stream } from "effect"
import { R } from "./reffuse"
export class QueryErrorHandler extends ErrorHandler.Tag("QueryErrorHandler")<QueryErrorHandler,
HttpClientError.HttpClientError
>() {}
export const QueryErrorHandlerLive = ErrorHandler.layer(QueryErrorHandler)
export function VQueryErrorHandler() {
R.useFork(() => QueryErrorHandler.pipe(Effect.flatMap(handler =>
Stream.runForEach(handler.errors, flow(
Cause.failures,
Chunk.map(flow(Match.value,
Match.tag("RequestError", () => Effect.sync(() => {})),
Match.tag("ResponseError", () => Effect.sync(() => {})),
Match.exhaustive,
)),
Effect.all,
))
)), [])
}