GeezerVison is showing github.com — fix: Replace empty catch blocks with proper error logging by Kamkmgamer · Pull Request #8271 · anomalyco/opencode
Conversation
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Previously, image paste failures were silently ignored. Now we log
the error with a debug message when pasting an image fails, falling
back to text insertion.
|
Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
- Open an issue describing the bug/feature (if one doesn't exist)
- Add
Fixes #<number> or Closes #<number> to this PR description
See CONTRIBUTING.md for details.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate:
No duplicate PRs found
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.