mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-06 22:03:59 -05:00
fix(frontend): improve error message extraction in agent execution error handler (#11527)
When agent execution fails, the error toast was only showing `error.message`, which often lacks detail. The API returns more specific error messages in `error.response.detail.message`, but these weren't being displayed to users, making debugging harder. <img width="1018" height="796" alt="Screenshot 2025-12-03 at 2 14 17 PM" src="https://github.com/user-attachments/assets/6a93aed9-9e18-450a-9995-8760d7d5ca35" /> ### Changes 🏗️ - Updated error message extraction in `useAgentRunModal` to check `error.response.detail.message` first, then fall back to `error.message`, then to the default message - This ensures users see the most specific error message available from the API response ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Triggered an agent execution error (e.g., invalid inputs) and verified the toast shows the detailed error message from `error.response.detail.message` - [x] Verified fallback to `error.message` when `error.response.detail.message` is not available - [x] Verified fallback to default message when neither is available
This commit is contained in:
@@ -87,9 +87,13 @@ export function useAgentRunModal(
|
||||
}
|
||||
},
|
||||
onError: (error: any) => {
|
||||
const errorMessage = error.isGraphValidationError()
|
||||
? error.response.detail.message
|
||||
: error.message;
|
||||
|
||||
toast({
|
||||
title: "❌ Failed to execute agent",
|
||||
description: error.message || "An unexpected error occurred.",
|
||||
description: errorMessage || "An unexpected error occurred.",
|
||||
variant: "destructive",
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user