Skip to content

fix: improve error handling to surface proper error messages#13

Merged
Davis10733 merged 2 commits intomainfrom
fix/error-handling
Apr 4, 2026
Merged

fix: improve error handling to surface proper error messages#13
Davis10733 merged 2 commits intomainfrom
fix/error-handling

Conversation

@yeppyworld66
Copy link
Copy Markdown
Contributor

Problem

When LLM API calls fail, axios errors were caught but only err.message was displayed — giving generic messages like "Request failed with status code 401" instead of the actual API error details in err.response.data.

Changes

  • New helper src/lib/utils/error.tsextractErrorMessage() consistently extracts the best error message from any error (axios or otherwise), preferring err.response.data.error.messageJSON.stringify(err.response.data)err.message
  • Claude adapter — wraps axios errors with meaningful messages including API response body
  • OpenAI adapter — same treatment
  • call_api handler — uses extractErrorMessage for better error reporting in step logs
  • CLI test command — displays full error details from API responses

- Add extractErrorMessage() helper in src/lib/utils/error.ts
- Claude/OpenAI adapters now wrap axios errors with API response details
- call_api handler uses extractErrorMessage for better error info
- CLI test command displays full error details from API responses
Comment thread src/cli/commands/test.ts Outdated
}
} catch (err: any) {
console.error(`\n❌ Error: ${err.message}`);
const { extractErrorMessage } = await import('../../lib/utils/error');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think loading the default function in the top of the file and use it here is a much better patten.

@Davis10733 Davis10733 merged commit 335b5f2 into main Apr 4, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants