Fix error handling in Graph API endpoints - use 502 status and add logging

This commit is contained in:
2025-12-31 03:06:02 +00:00
parent 6dc58c2fc3
commit 14327e219d
+3 -2
View File
@@ -387,7 +387,8 @@ app.get('/api/job-file-content', async (c) => {
});
if (!res.ok) {
const text = await res.text();
return c.json({ error: `Graph ${res.status}: ${text}` }, res.status);
logLine('logs/error.log', `/api/job-file-content failed: ${res.status} - ${text}`);
return c.json({ error: `Graph ${res.status}: ${text}` }, 502);
}
const headers: Record<string, string> = {};
const ct = res.headers.get('content-type');
@@ -419,7 +420,7 @@ app.get('/api/job-file-pdf', async (c) => {
if (!res.ok) {
const text = await res.text();
logLine('logs/error.log', `/api/job-file-pdf conversion failed: ${res.status} - ${text}`);
return c.json({ error: `PDF conversion failed: ${res.status}` }, res.status);
return c.json({ error: `PDF conversion failed: ${res.status}` }, 502);
}
const headers: Record<string, string> = {
'Content-Type': 'application/pdf',