fix: Error Handling in Backend und Frontend verbessern (Phase 5, Schritt 31)
- Backend: JSON-Parse-Error + Payload-Too-Large Middleware in index.js - Backend: Dashboard äußerer try/catch für db.get()-Fehler - Backend: contacts/meta Route mit try/catch - Frontend: try/catch + Toast-Fallback in loadMonth (budget), loadRange (calendar), loadWeek (meals), loadLists/switchList (shopping), initiales Laden (notes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -67,6 +67,17 @@ app.set('trust proxy', 1);
|
||||
app.use(express.json({ limit: '1mb' }));
|
||||
app.use(express.urlencoded({ extended: true, limit: '1mb' }));
|
||||
|
||||
// JSON-Parse-Fehler abfangen (gibt sonst HTML zurück)
|
||||
app.use((err, req, res, next) => {
|
||||
if (err.type === 'entity.parse.failed') {
|
||||
return res.status(400).json({ error: 'Ungültiges JSON im Request-Body.', code: 400 });
|
||||
}
|
||||
if (err.type === 'entity.too.large') {
|
||||
return res.status(413).json({ error: 'Request-Body zu groß (max. 1 MB).', code: 413 });
|
||||
}
|
||||
next(err);
|
||||
});
|
||||
|
||||
// --------------------------------------------------------
|
||||
// Sessions
|
||||
// --------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user