mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 12:42:38 +00:00
error handler hardened
This commit is contained in:
@@ -1 +1 @@
|
||||
797
|
||||
798
|
||||
|
||||
@@ -131,12 +131,14 @@ public static class ResponseHelper
|
||||
{
|
||||
return ex switch
|
||||
{
|
||||
RequestFailedException rfe when rfe.ErrorCode != null =>
|
||||
$"{operation}: {rfe.ErrorCode} — {rfe.Message}",
|
||||
RequestFailedException rfe =>
|
||||
$"{operation}: {rfe.ErrorCode ?? $"Azure error (HTTP {rfe.Status})"} — {rfe.Message}",
|
||||
$"{operation}: Azure error (HTTP {rfe.Status}). Use correlationId to investigate in backend logs.",
|
||||
ArgumentException ae =>
|
||||
$"{operation}: Invalid argument — {ae.Message}",
|
||||
InvalidOperationException ioe =>
|
||||
$"{operation}: {ioe.Message}",
|
||||
InvalidOperationException =>
|
||||
$"{operation}: Invalid operation. Use correlationId to investigate in backend logs.",
|
||||
TimeoutException =>
|
||||
$"{operation}: The operation timed out",
|
||||
TaskCanceledException =>
|
||||
|
||||
@@ -40,7 +40,9 @@ export function toolError(
|
||||
} else if (error.status === 429) {
|
||||
parts.push(`**Rate limited in ${toolName}**: Too many requests. Wait a moment and retry.`);
|
||||
} else {
|
||||
parts.push(`**Error in ${toolName}** (HTTP ${error.status}): ${error.body || 'No response body'}`);
|
||||
const body = error.body || 'No response body';
|
||||
const truncated = body.length > 500 ? body.slice(0, 500) + '…' : body;
|
||||
parts.push(`**Error in ${toolName}** (HTTP ${error.status}): ${truncated}`);
|
||||
}
|
||||
} else {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
|
||||
Reference in New Issue
Block a user