MCPcopy
hub / github.com/Effect-TS/effect / makeErrorSchema

Function makeErrorSchema

packages/platform/src/HttpApiBuilder.ts:770–782  ·  view source on GitHub ↗
(
  api: HttpApi.HttpApi.AnyWithProps
)

Source from the content-addressed store, hash-verified

768}
769
770const makeErrorSchema = (
771 api: HttpApi.HttpApi.AnyWithProps
772): Schema.Schema<unknown, HttpServerResponse.HttpServerResponse> => {
773 const schemas = new Set<Schema.Schema.Any>()
774 HttpApiSchema.deunionize(schemas, api.errorSchema)
775 for (const group of Object.values(api.groups)) {
776 for (const endpoint of Object.values(group.endpoints)) {
777 HttpApiSchema.deunionize(schemas, endpoint.errorSchema)
778 }
779 HttpApiSchema.deunionize(schemas, group.errorSchema)
780 }
781 return Schema.Union(...Array.from(schemas, toResponseError)) as any
782}
783
784const decodeForbidden = <A>(_: A, __: AST.ParseOptions, ast: AST.Transformation) =>
785 ParseResult.fail(new ParseResult.Forbidden(ast, _, "Encode only schema"))

Callers 1

HttpApiBuilder.tsFile · 0.85

Calls 1

valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…