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

Function makeErrorSchema

packages/effect/src/http-api/HttpApiBuilder.ts:1414–1423  ·  view source on GitHub ↗
(
  endpoint: HttpApiEndpoint.Top,
  headersOptions: SchemaAST.ParseOptions | undefined
)

Source from the content-addressed store, hash-verified

1412}
1413
1414function makeErrorSchema(
1415 endpoint: HttpApiEndpoint.Top,
1416 headersOptions: SchemaAST.ParseOptions | undefined
1417): Schema.ConstraintEncoder<HttpServerResponse, unknown> {
1418 const schemas = HttpApiEndpoint.getErrorSchemas(endpoint).map((schema) =>
1419 toResponseErrorSchema(schema, headersOptions)
1420 )
1421 if (schemas.length === 0) return Schema.Never
1422 return schemas.length === 1 ? schemas[0] : Schema.Union(schemas)
1423}
1424
1425function toResponseSchema(getStatus: (schema: Schema.Constraint) => number) {
1426 // WithHeaders wrappers share a single declaration AST, so they are cached by instance

Callers 1

handlerToHttpEffectFunction · 0.70

Calls 2

toResponseErrorSchemaFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected