MCPcopy Create free account
hub / github.com/pollinations/pollinations / createErrorResponseSchema

Function createErrorResponseSchema

shared/error.ts:118–140  ·  view source on GitHub ↗
(
    status: ContentfulStatusCode,
)

Source from the content-addressed store, hash-verified

116 .meta({ $id: "ValidationErrorDetails" });
117
118export function createErrorResponseSchema(
119 status: ContentfulStatusCode,
120): z.ZodObject {
121 const errorDetailsSchema =
122 status === 400
123 ? ValidationErrorDetailsSchema
124 : GenericErrorDetailsSchema;
125 return z.object({
126 status: z.literal(status),
127 success: z.literal(false),
128 error: z.object({
129 code: z.literal(getErrorCode(status)),
130 message: z.union([
131 z.literal(getDefaultErrorMessage(status)),
132 z.string(),
133 ]),
134 timestamp: z.string(),
135 details: errorDetailsSchema,
136 requestId: z.string().optional(),
137 cause: z.unknown().optional(),
138 }),
139 });
140}
141
142export const GenericErrorResponseSchema = z.object({
143 status: z.number().int().min(100).max(599),

Callers 2

error.tsFile · 0.85

Calls 2

getErrorCodeFunction · 0.85
getDefaultErrorMessageFunction · 0.85

Tested by

no test coverage detected