Files
klz-cables.com/.pnpm-store/v10/files/e8/e149ef697417b28e15e8a15d7cb23c5c5eb2ad4fb35a3106bd6a1780f5a44cf1c52d631f642453f10bae67b9d58b53f4f53a3458e33681c802acef256053ef
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

1 line
5.9 KiB
Plaintext

{"version":3,"sources":["../../src/utilities/routeError.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { Collection } from '../collections/config/types.js'\nimport type { ErrorResult, SanitizedConfig } from '../config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from '../errors/APIError.js'\nimport { getPayload } from '../index.js'\nimport { formatErrors } from './formatErrors.js'\nimport { headersWithCors } from './headersWithCors.js'\nimport { isErrorPublic } from './isErrorPublic.js'\nimport { logError } from './logError.js'\nimport { mergeHeaders } from './mergeHeaders.js'\n\nexport const routeError = async ({\n collection,\n config: configArg,\n err,\n req: incomingReq,\n}: {\n collection?: Collection\n config: Promise<SanitizedConfig> | SanitizedConfig\n err: APIError\n req: PayloadRequest | Request\n}): Promise<Response> => {\n if ('payloadInitError' in err && err.payloadInitError === true) {\n // do not attempt initializing Payload if the error is due to a failed initialization. Otherwise,\n // it will cause an infinite loop of initialization attempts and endless error responses, without\n // actually logging the error, as the error logging code will never be reached.\n console.error(err)\n return Response.json(\n {\n message: 'There was an error initializing Payload',\n },\n { status: httpStatus.INTERNAL_SERVER_ERROR },\n )\n }\n\n let payload = incomingReq && 'payload' in incomingReq && incomingReq?.payload\n\n if (!payload) {\n try {\n payload = await getPayload({ config: configArg, cron: true })\n } catch (ignore) {\n return Response.json(\n {\n message: 'There was an error initializing Payload',\n },\n { status: httpStatus.INTERNAL_SERVER_ERROR },\n )\n }\n }\n\n let response = formatErrors(err)\n\n let status = err.status || httpStatus.INTERNAL_SERVER_ERROR\n\n logError({ err, payload })\n\n const req = incomingReq as PayloadRequest\n\n req.payload = payload\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const { config } = payload\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!isErrorPublic(err, config)) {\n response = formatErrors(new APIError('Something went wrong.'))\n }\n\n if (config.debug && config.debug === true) {\n response.stack = err.stack\n }\n\n if (collection) {\n await collection.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n collection: collection.config,\n context: req.context,\n error: err,\n req,\n result: response,\n })\n\n if (result) {\n response = (result.response as ErrorResult) || response\n status = result.status || status\n }\n }, Promise.resolve())\n }\n\n await config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n collection: collection?.config,\n context: req.context,\n error: err,\n req,\n result: response,\n })\n\n if (result) {\n response = (result.response as ErrorResult) || response\n status = result.status || status\n }\n }, Promise.resolve())\n\n return Response.json(response, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, headers) : headers,\n status,\n })\n}\n"],"names":["status","httpStatus","APIError","getPayload","formatErrors","headersWithCors","isErrorPublic","logError","mergeHeaders","routeError","collection","config","configArg","err","req","incomingReq","payloadInitError","console","error","Response","json","message","INTERNAL_SERVER_ERROR","payload","cron","ignore","response","headers","Headers","debug","stack","hooks","afterError","reduce","promise","hook","result","context","Promise","resolve","responseHeaders"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAMlD,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,UAAU,QAAQ,cAAa;AACxC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,eAAe,Q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