Improve unsupported PDF character errors
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 30s
Build and Push Docker Images / build-frontend (push) Successful in 1m12s
Build and Push Docker Images / build-website (push) Successful in 18s
Build and Push Docker Images / build-docs (push) Successful in 17s

This commit is contained in:
2026-07-24 10:25:10 +02:00
parent 4ab4c24b1a
commit d3ad53bcf0
4 changed files with 121 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ import { s3 } from "../utils/s3";
import { secrets } from "../utils/secrets";
import { storeExtractedTextForFile } from "../utils/documentText";
import { generateLiquidityForecast } from "../utils/liquidityForecast";
import { getUnsupportedPdfCharacterMessage } from "../utils/pdfCharacterError";
dayjs.extend(customParseFormat)
dayjs.extend(isoWeek)
dayjs.extend(isBetween)
@@ -134,7 +135,15 @@ export default async function functionRoutes(server: FastifyInstance) {
return pdf // Fastify wandelt automatisch in JSON
} catch (err) {
console.log(err)
reply.code(500).send({ error: "Failed to create PDF" })
const unsupportedCharacterMessage = getUnsupportedPdfCharacterMessage(err, body.data)
if (unsupportedCharacterMessage) {
return reply.code(422).send({
error: unsupportedCharacterMessage,
code: "UNSUPPORTED_PDF_CHARACTER",
})
}
return reply.code(500).send({ error: "Failed to create PDF" })
}
})