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

Function createUpstreamErrorResponse

shared/error.ts:297–317  ·  view source on GitHub ↗
(
    error: UpstreamError,
    status: ContentfulStatusCode,
    timestamp: string,
)

Source from the content-addressed store, hash-verified

295}
296
297function createUpstreamErrorResponse(
298 error: UpstreamError,
299 status: ContentfulStatusCode,
300 timestamp: string,
301): ErrorResponse {
302 return createErrorResponse(
303 error,
304 status,
305 timestamp,
306 {
307 name: error.name,
308 upstreamStatus: error.upstreamStatus,
309 upstreamHost: error.requestUrl?.hostname,
310 upstreamBody: truncateString(
311 error.responseBody,
312 MAX_UPSTREAM_BODY_LENGTH,
313 ),
314 },
315 error.errorCode,
316 );
317}
318
319/**
320 * Remap upstream 4xx statuses that are our operational concern (auth, routing,

Callers 1

handleErrorFunction · 0.85

Calls 2

createErrorResponseFunction · 0.85
truncateStringFunction · 0.85

Tested by

no test coverage detected