Log Workforce departments error to aid debugging

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-02 00:53:53 +00:00
parent 6742204546
commit da657ab6c7

View file

@ -226,7 +226,10 @@ export async function adminRoutes(app) {
app.get('/workforce/departments', async (request, reply) => { app.get('/workforce/departments', async (request, reply) => {
let depts let depts
try { depts = await getAllDepartments() } try { depts = await getAllDepartments() }
catch (err) { return reply.status(502).send({ error: `Workforce API error: ${err.message}` }) } catch (err) {
request.log.error({ err }, 'Workforce departments fetch failed')
return reply.status(502).send({ error: `Workforce API error: ${err.message}` })
}
const { rows: mappings } = await pool.query('SELECT department_id, role_id FROM workforce_department_roles') const { rows: mappings } = await pool.query('SELECT department_id, role_id FROM workforce_department_roles')
const mappingMap = Object.fromEntries(mappings.map(m => [m.department_id, m.role_id])) const mappingMap = Object.fromEntries(mappings.map(m => [m.department_id, m.role_id]))