MCPcopy Create free account
hub / github.com/Effect-TS/effect / normalizeError

Function normalizeError

packages/effect/src/unstable/ai/Toolkit.ts:352–371  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

350 )
351
352 const normalizeError = (error: unknown) => {
353 // Schema errors indicate handler returned invalid data
354 const normalizedError = Schema.isSchemaError(error)
355 ? AiError.make({
356 module: "Toolkit",
357 method: `${name}.handle`,
358 reason: new AiError.InvalidToolResultError({
359 toolName: name,
360 description: `Tool handler returned invalid result: ${error.message}`
361 })
362 })
363 : AiError.isAiErrorReason(error)
364 ? AiError.make({
365 module: "Toolkit",
366 method: `${name}.handle`,
367 reason: error
368 })
369 : error
370 return normalizedError
371 }
372
373 return Stream.fromQueue(queue).pipe(
374 // If the tool handler failed, check the tool's failure mode to

Callers 1

Toolkit.tsFile · 0.85

Calls 1

makeMethod · 0.65

Tested by

no test coverage detected