Skip to content

🐛 fix(generateCommitMsg): enhance error handling and logging for API failures#39

Open
adihanifsdr wants to merge 2 commits intoSitoi:mainfrom
adihanifsdr:main
Open

🐛 fix(generateCommitMsg): enhance error handling and logging for API failures#39
adihanifsdr wants to merge 2 commits intoSitoi:mainfrom
adihanifsdr:main

Conversation

@adihanifsdr
Copy link
Contributor

@adihanifsdr adihanifsdr commented Feb 20, 2026

Summary

  • Add a Logger class with a VSCode Output Channel (AI Commit) for structured, timestamped logging (INFO/WARN/ERROR)
  • Replace all console.error() calls with Logger.error() across the codebase so logs appear in the Output panel instead of only the Developer Tools console
  • Add info-level logging for key operations: extension activation, command execution, AI provider selection, and successful commit message generation
  • Fix error handling in generateCommitMsg: preserve the original err.message instead of always showing "An unexpected error occurred", and also check err.status (newer OpenAI SDK) in addition to err.response?.status

Changes

File Change
src/logger.ts New — Logger class with VSCode OutputChannel, Error serialization support
src/extension.ts Initialize/dispose Logger, log activation lifecycle
src/commands.ts Log command execution and failures
src/generate-commit-msg.ts Log API provider, success/failure; fix error swallowing
src/config.ts Replace console.error with Logger.error
src/git-utils.ts Replace console.error with Logger.error
src/gemini-utils.ts Replace console.error with Logger.error

How to view logs

  1. Open the Output panel: Ctrl+Shift+U
  2. Select "AI Commit" from the dropdown
  3. Logs appear with timestamps and level indicators

Test plan

  • Verify "AI Commit" appears in the Output panel dropdown after activation
  • Trigger a commit message generation and confirm INFO logs appear
  • Trigger an API error and confirm the full error message and stack trace appear in the Output panel
  • Confirm the error notification now shows the actual error message instead of "An unexpected error occurred"

@adihanifsdr
Copy link
Contributor Author

Please check @Sitoi

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.

1 participant