diff --git a/backend/controllers/falukantController.js b/backend/controllers/falukantController.js index e7db3d4..d1df872 100644 --- a/backend/controllers/falukantController.js +++ b/backend/controllers/falukantController.js @@ -263,7 +263,13 @@ class FalukantController { } catch (error) { console.error('Controller error:', error); const status = error.status && typeof error.status === 'number' ? error.status : 500; - res.status(status).json({ error: error.message || 'Internal error' }); + // Wenn error ein Objekt mit status ist, alle Felder außer status übernehmen + if (error && typeof error === 'object' && error.status && typeof error.status === 'number') { + const { status: errorStatus, ...errorData } = error; + res.status(errorStatus).json({ error: error.message || errorData.message || 'Internal error', ...errorData }); + } else { + res.status(status).json({ error: error.message || 'Internal error' }); + } } }; }