fix: wrap client_create/delete/update in try/except for proper error surfacing

This commit is contained in:
wasrusgen 2026-05-16 12:35:42 +03:00
parent b3b62fa902
commit 632bce8f33

View File

@ -270,19 +270,31 @@ async def api_client_note(request: Request):
@app.post("/api/client_create") @app.post("/api/client_create")
async def api_client_create(request: Request): async def api_client_create(request: Request):
body = await _safe_json(request) body = await _safe_json(request)
return _handle_client_create(body) try:
return _handle_client_create(body)
except Exception as e:
log.exception("client_create error")
return JSONResponse({"error": str(e)}, status_code=500)
@app.post("/api/client_delete") @app.post("/api/client_delete")
async def api_client_delete(request: Request): async def api_client_delete(request: Request):
body = await _safe_json(request) body = await _safe_json(request)
return _handle_client_delete(body) try:
return _handle_client_delete(body)
except Exception as e:
log.exception("client_delete error")
return JSONResponse({"error": str(e)}, status_code=500)
@app.post("/api/client_update") @app.post("/api/client_update")
async def api_client_update(request: Request): async def api_client_update(request: Request):
body = await _safe_json(request) body = await _safe_json(request)
return _handle_client_update(body) try:
return _handle_client_update(body)
except Exception as e:
log.exception("client_update error")
return JSONResponse({"error": str(e)}, status_code=500)
@app.post("/api/measurement_design_upload") @app.post("/api/measurement_design_upload")