Skip to content
Source
Sign inSign up
pingdotgg/t3code

[codex] Structure ACP transport errors #3251

Mergedjuliusmarmingemerged 10 commits intomain fromrefs/pull/3251/headmerged by juliusmarminge View on GitHub

Showing 10 changed files with 74 additions and 68 deletions (loading 7).

x
0 of 10 viewed, 10 left
19 additions and 27 deletionspackages/effect-acp/src/_internal/shared.tsModified
View file
@@ -1,30 +1,29 @@
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
-import * as SchemaIssue from "effect/SchemaIssue";
import { RpcClientError } from "effect/unstable/rpc";
​
import * as AcpSchema from "../_generated/schema.gen.ts";
import * as AcpError from "../errors.ts";
const isError = Schema.is(AcpSchema.Error);
-const isAcpRequestError = Schema.is(AcpError.AcpRequestError);
-​
-const formatSchemaIssue = SchemaIssue.makeFormatterDefault();
​
export const callRpc = <A>(
+ method: string,
effect: Effect.Effect<A, RpcClientError.RpcClientError | AcpSchema.Error>,
): Effect.Effect<A, AcpError.AcpError> =>
effect.pipe(
- Effect.catchTag("RpcClientError", (error) =>
- Effect.fail(
- new AcpError.AcpTransportError({
- detail: error.message,
- cause: error,
- }),
- ),
- ),
Effect.catchIf(isError, (error) =>
Effect.fail(AcpError.AcpRequestError.fromProtocolError(error)),
),
+ Effect.catchTags({
+ RpcClientError: (cause) =>