fix: add explanatory comments to empty catch blocks in browser finder#1848
Open
cxybd wants to merge 1 commit intobytedance:mainfrom
Open
fix: add explanatory comments to empty catch blocks in browser finder#1848cxybd wants to merge 1 commit intobytedance:mainfrom
cxybd wants to merge 1 commit intobytedance:mainfrom
Conversation
✅ Deploy Preview for tarko canceled.
|
✅ Deploy Preview for agent-tars-docs canceled.
|
- Add clear comments explaining why exceptions are caught and ignored - Improves code readability and maintainability - Makes it clear that exceptions are expected when browsers are not installed Severity: Low-Medium (3-4/10)
517835e to
49fceaf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🐛 Problem
Empty catch blocks in browser path finding functions silently swallow errors without explanation:
This makes the code:
✅ Solution
Add clear explanatory comments to document the intentional behavior:
The comments clarify:
📝 Changes
Files modified:
packages/agent-infra/browser/src/browser-finder/chrome-paths.tspackages/agent-infra/browser/src/browser-finder/firefox-paths.tsWhat changed:
Code diff:
try { for (const name of list) { const path = which.sync(name); return path; } } catch (e) { + // which.sync() throws when command not found - this is expected + // when Chrome/Firefox is not installed on the system. Continue trying other methods. }Statistics:
🧪 Testing
Expected behavior:
nullwhen browser not foundBrowserFinderhandles the null return appropriately📊 Severity & Impact
Severity: Low-Medium (3-4/10)
Type: Code quality / Documentation improvement
Impact:
Risk: None
🔍 Related Issues
Addresses empty catch blocks that could cause confusion during code review and maintenance. Improves code documentation following best practices.