Skip to content

Conversation

@Kamkmgamer
Copy link
Contributor

Summary

This PR fixes 7 instances of empty catch blocks across 5 files that were silently swallowing errors, making debugging difficult and potentially masking critical failures.

Changes Made

1. packages/opencode/src/session/message-v2.ts

  • Added Log import for error logging
  • Replaced empty catch block in error response parsing with debug logging
  • Impact: Improves debugging of API error responses

2. packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

  • Added Log import for error logging
  • Replaced empty catch block in image paste handling with debug logging
  • Impact: Improves debugging of clipboard/paste operations

3. packages/opencode/src/session/retry.ts

  • Added Log import for error logging
  • Replaced empty catch block in error response parsing with debug logging
  • Impact: Improves debugging of retry mechanism

4. packages/opencode/src/pty/index.ts

  • Replaced two empty catch blocks with debug logging for process termination
  • Uses existing logger instance (Log.create({ service: "pty" }))
  • Impact: Improves debugging of PTY session management

5. packages/opencode/src/server/mdns.ts

  • Replaced empty catch block with debug logging for bonjour instance cleanup
  • Uses existing logger instance (Log.create({ service: "mdns" }))
  • Impact: Improves debugging of mDNS service discovery

Technical Details

  • ✅ Uses existing Log utility throughout codebase
  • ✅ Uses Log.Default.debug() and existing logger instances appropriately
  • ✅ Adds descriptive error messages with error context
  • ✅ Maintains existing control flow and error handling behavior
  • ✅ Only adds observability, no functional changes
  • ✅ Follows project's error handling preferences (prefer logging over silent failures)

Testing

  • All changes maintain existing behavior
  • No functionality changes, only observability improvements
  • Compatible with existing test suite

Impact

  • Improved Debugging: All error scenarios now logged at debug level
  • Zero Breaking Changes: Maintains existing behavior while adding observability
  • Production Ready: Uses existing logging infrastructure
  • Maintainable: Clear, descriptive log messages for future debugging

Files Changed

  • 5 files modified
  • 7 empty catch blocks replaced with proper error logging
  • 3 new Log imports added (2 files already had Log imported)

Verification

  • ✅ All changes follow existing code patterns
  • ✅ Uses established logging infrastructure
  • ✅ No changes to business logic or error handling behavior
  • ✅ Improves codebase maintainability and debuggability

Related Issues

Addresses technical debt identified in codebase review where empty catch blocks were silently swallowing errors, making production debugging nearly impossible.

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant