Skip to content

Conversation

@theabhishekbhujang
Copy link

Add try-catch block around onProgress call to handle potential errors.

Add try-catch block around onProgress call to handle potential errors.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds error handling around a progress callback invocation to prevent potential errors from breaking the translation flow. While this is a step in the right direction, the implementation has some issues that should be addressed.

Key Changes

  • Wrapped the final onProgress(100, {}, result) call in a try-catch block to handle potential errors
  • Added error handling specifically at the completion stage of translation processing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


try {
onProgress(100, {}, result);
} catch {}
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The empty catch block silently swallows any errors from onProgress, making debugging difficult. Consider at least logging the error:

try {
  onProgress(100, {}, result);
} catch (error) {
  console.error('Error during progress update:', error);
}

This will help identify issues while still preventing the error from breaking the translation flow.

Suggested change
} catch {}
} catch (error) {
console.error('Error during progress update:', error);
}

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +32
try {
onProgress(100, {}, result);
} catch {}
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Error handling is inconsistent - the onProgress call at line 25 (inside the loop) doesn't have error handling, but this final call at line 31 does. Consider applying the same error handling pattern to both locations for consistency. If errors in progress callbacks could occur during chunk processing, they should also be handled there.

Copilot uses AI. Check for mistakes.
@sumitsaurabh927
Copy link
Contributor

@theabhishekbhujang please resolve comments

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