fix: wrap executeActionsWithLoop in try/catch to prevent raw 500 errors

When the AI Gateway returns a non-200 (e.g. tool validation failure),
callWebhook throws an unhandled Error that bubbled up to Slim as a raw
500 page. Now caught gracefully with a Hebrew error message returned
to the user instead of "Slim Application Error".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 20:51:06 +00:00
parent 59fc8acdc4
commit 1bb0c06345
2 changed files with 13 additions and 5 deletions
@@ -122,10 +122,18 @@ class SmartAssistantService
} }
// Execute tools with agentic loop — read tools feed results back to AI // Execute tools with agentic loop — read tools feed results back to AI
$loopResult = $this->executeActionsWithLoop( try {
$message, $context, $conversationId, $conversationHistory, $loopResult = $this->executeActionsWithLoop(
$mode, $effectiveCaseId, $userId $message, $context, $conversationId, $conversationHistory,
); $mode, $effectiveCaseId, $userId
);
} catch (\Exception $e) {
$this->log->error("SmartAssistant: Chat failed: " . $e->getMessage());
$loopResult = [
'responseText' => "⚠️ אירעה שגיאה בתקשורת עם המערכת. אנא נסה שוב בעוד מספר דקות.\n\nפרטי השגיאה: " . $e->getMessage(),
'executedActions' => [],
];
}
$responseText = $loopResult['responseText']; $responseText = $loopResult['responseText'];
$executedActions = $loopResult['executedActions']; $executedActions = $loopResult['executedActions'];
+1 -1
View File
@@ -3,7 +3,7 @@
"module": "SmartAssistant", "module": "SmartAssistant",
"description": "Unified AI Assistant for Legal CRM — floating chat with case memory, office alerts, and AI Gateway integration", "description": "Unified AI Assistant for Legal CRM — floating chat with case memory, office alerts, and AI Gateway integration",
"author": "klear", "author": "klear",
"version": "2.7.0", "version": "2.7.1",
"acceptableVersions": [ "acceptableVersions": [
">=8.0.0" ">=8.0.0"
], ],