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

Function makeErrorSchema

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

Source from the content-addressed store, hash-verified

779}
780
781const makeErrorSchema = (
782 api: HttpApi.HttpApi.AnyWithProps
783): Schema.Schema<unknown, HttpServerResponse.HttpServerResponse> => {
784 const schemas = new Set<Schema.Schema.Any>()
785 HttpApiSchema.deunionize(schemas, api.errorSchema)
786 for (const group of Object.values(api.groups)) {
787 for (const endpoint of Object.values(group.endpoints)) {
788 HttpApiSchema.deunionize(schemas, endpoint.errorSchema)
789 }
790 HttpApiSchema.deunionize(schemas, group.errorSchema)
791 }
792 return Schema.Union(...Array.from(schemas, toResponseError)) as any
793}
794
795const decodeForbidden = <A>(_: A, __: AST.ParseOptions, ast: AST.Transformation) =>
796 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