(code: z.ZodEnum<any>)
| 23 | ]); |
| 24 | |
| 25 | export function errorSchemaFactory(code: z.ZodEnum<any>) { |
| 26 | return z.object({ |
| 27 | error: z.object({ |
| 28 | code: code.openapi({ |
| 29 | description: 'A machine readable error code.', |
| 30 | example: code._def.values.at(0) |
| 31 | }), |
| 32 | docs: z.string().openapi({ |
| 33 | description: |
| 34 | 'A link to our documentation with more details about this error code', |
| 35 | example: `https://langbase.com/docs/api-reference/errors/${code._def.values |
| 36 | .at(0) |
| 37 | .toLowerCase()}` |
| 38 | }), |
| 39 | message: z.string().openapi({ |
| 40 | description: 'A human readable explanation of what went wrong' |
| 41 | }) |
| 42 | }) |
| 43 | }); |
| 44 | } |
| 45 | |
| 46 | export const ErrorSchema = z.object({ |
| 47 | success: z.literal(false).openapi({ |
nothing calls this directly
no outgoing calls
no test coverage detected