fix(api): add error handling to /api/staff/me endpoint
Wrap c.json() in try/catch to surface serialization errors rather than crashing silently. Also guard against null staff context. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -25,7 +25,15 @@ const updateStaffSchema = z.object({
|
|||||||
|
|
||||||
staffRouter.get("/me", async (c) => {
|
staffRouter.get("/me", async (c) => {
|
||||||
const staffRow = c.get("staff");
|
const staffRow = c.get("staff");
|
||||||
return c.json(staffRow);
|
if (!staffRow) {
|
||||||
|
return c.json({ error: "Staff record not found in context" }, 500);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return c.json(staffRow);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("[/api/staff/me] serialization error:", err, "staffRow:", staffRow);
|
||||||
|
return c.json({ error: "Serialization error", detail: String(err) }, 500);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
staffRouter.get("/", async (c) => {
|
staffRouter.get("/", async (c) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user