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

Function createErrorResponse

shared/error.ts:255–273  ·  view source on GitHub ↗

* Creates a standardized error response

(
    error: Error,
    status: ContentfulStatusCode,
    timestamp: string,
    details?: Record<string, unknown>,
    code?: string,
)

Source from the content-addressed store, hash-verified

253 * Creates a standardized error response
254 */
255function createErrorResponse(
256 error: Error,
257 status: ContentfulStatusCode,
258 timestamp: string,
259 details?: Record<string, unknown>,
260 code?: string,
261): ErrorResponse {
262 return {
263 success: false,
264 error: {
265 message: error.message || getDefaultErrorMessage(status),
266 code: code ?? getErrorCode(status),
267 timestamp,
268 ...(details && { details }),
269 ...(!!error.cause && { cause: error.cause }),
270 },
271 status,
272 };
273}
274
275function createValidationErrorResponse(
276 error: ValidationError,

Callers 4

handleErrorFunction · 0.85

Calls 2

getDefaultErrorMessageFunction · 0.85
getErrorCodeFunction · 0.85

Tested by

no test coverage detected