| @@ -1,7 +1,7 @@ |
| 1 | 1 | import type { StandardSchemaV1 } from "@standard-schema/spec"; |
| 2 | 2 | import * as Effect from "effect/Effect"; |
| 3 | 3 | |
| 4 | | −import { kernelCoreEffectError } from "./effect-errors"; |
| 4 | +import { KernelCoreEffectError } from "./effect-errors"; |
| 5 | 5 | |
| 6 | 6 | const getSchemaValidator = ( |
| 7 | 7 | schema: unknown, |
| @@ -55,25 +55,29 @@ export const validateInput = (input: { · 47 unmodified lines |
| 55 | 55 | const validate = getSchemaValidator(input.schema); |
| 56 | 56 | if (!validate) { |
| 57 | 57 | return Effect.fail( |
| 58 | | − kernelCoreEffectError( |
| 59 | | − "validation", |
| 60 | | − `Tool ${input.path} has no Standard Schema validator on inputSchema`, |
| 61 | | − ), |
| 58 | + new KernelCoreEffectError({ |
| 59 | + module: "validation", |
| 60 | + message: `Tool ${input.path} has no Standard Schema validator on inputSchema`, |
| 61 | + }), |
| 62 | 62 | ); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | return Effect.tryPromise({ |
| 66 | 66 | try: () => Promise.resolve(validate(input.value)), |
| 67 | 67 | catch: (cause) => |
| 68 | | − kernelCoreEffectError("validation", `Validation error for ${input.path}: ${String(cause)}`), |
| 68 | + new KernelCoreEffectError({ |
| 69 | + module: "validation", |
| 70 | + message: `Validation error for ${input.path}`, |
| 71 | + cause, |
| 72 | + }), |
| 69 | 73 | }).pipe( |
| 70 | 74 | Effect.flatMap((result) => { |
| 71 | 75 | if ("issues" in result && result.issues) { |
| 72 | 76 | return Effect.fail( |
| 73 | | − kernelCoreEffectError( |
| 74 | | − "validation", |
| 75 | | − `Input validation failed for ${input.path}: ${formatIssues(result.issues)}`, |
| 76 | | − ), |
| 77 | + new KernelCoreEffectError({ |
| 78 | + module: "validation", |
| 79 | + message: `Input validation failed for ${input.path}: ${formatIssues(result.issues)}`, |
| 80 | + }), |
| 77 | 81 | ); |
| 78 | 82 | } |
| 79 | 83 | return Effect.succeed(result.value); |