From 15aab279ec31409aebc4b9f510ee2097c2b87822 Mon Sep 17 00:00:00 2001 From: Yamen Ahmad Date: Sun, 12 Apr 2026 03:19:30 +0400 Subject: [PATCH] fix: add proper error handling for AI generation and log failures Made-with: Cursor --- .../__pycache__/ai_controller.cpython-312.pyc | Bin 34005 -> 34118 bytes .../encoach_ai/controllers/ai_controller.py | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_addons/encoach_ai/controllers/__pycache__/ai_controller.cpython-312.pyc b/custom_addons/encoach_ai/controllers/__pycache__/ai_controller.cpython-312.pyc index b9271a17cade7449d68cb3926afd277b5ffc4852..c74c0be2e12089afb81785d1cbcc4fcf882e41fc 100644 GIT binary patch delta 441 zcmccG$#krXiT5-wFBbz4yuExYbHzs9HEv8<%##n=h)>>MZL^ureI66PWi3~U0!Rr6 zWGPR+XfJFoS;JVvwVD|s#>h}24Ph}bq%)ML!q`9+j1YE;)EuT1>D5e=uX-vo%547W zd4SQZN;h{j<}IaPSQzCu zudK3XW;EXXvi2E^kOHeW<7Z|DwmilUOd$3rm(35G?lOv}aWHx^PB58nKhgdx1DI1J H01N~G)G>*U delta 333 zcmX@s#dNikiT5-wFBbz4WGLOrjNZt*#*N8}dGbLU@yP}?HkQ4$}|Nh zFRYcEY~eG1@W5edW@EMGZHJjNZHJKT^Hyg%O zF*DBCye9rWJL9>@J?YOTcc=4jZp<)XVqCd-Q&v1H`x~Ie#giE(YnRDvHYxbP%J_S; zYS|YSM!C&W)%MJcMw_GRp0NnYv$`>UW@cc^WBkAbVt;bl9MpW5Q9PA{(UWn4$#naP N_FoymoFW0B=Kw}dVx|B9 diff --git a/custom_addons/encoach_ai/controllers/ai_controller.py b/custom_addons/encoach_ai/controllers/ai_controller.py index cc326aca..7f41dbcf 100644 --- a/custom_addons/encoach_ai/controllers/ai_controller.py +++ b/custom_addons/encoach_ai/controllers/ai_controller.py @@ -347,7 +347,8 @@ class AIController(http.Controller): ] return _json_response(ai.chat_json(messages, action=f"exam_generate_{module}")) except Exception as e: - return _json_response({"questions": [], "error": str(e)}) + _logger.exception("exam_generate %s failed: %s", module, e) + return _json_response({"questions": [], "error": str(e)}, 500) def _generate_passage(self, ai, body): topic = body.get("topic", "general knowledge")