Skip to content

Conversation

@theabhishekbhujang
Copy link

Add error handling for JSON parsing in response.

Add error handling for JSON parsing in response.
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 enhances error handling when parsing JSON responses from model APIs in the translation processor. The changes ensure that JSON parsing failures are caught and reported with clear error messages instead of allowing the application to crash with raw parsing errors.

  • Adds try-catch block around JSON.parse for model response handling
  • Adds empty try-catch for onProgress callback at function start
  • Provides descriptive error message when JSON parsing fails

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

return async (input: LocalizerInput, onProgress: LocalizerProgressFn) => {
try {
onProgress(0, {}, {});
} 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.

Empty catch block silences all errors without logging or handling them. If onProgress can fail, the error should be logged for debugging purposes. Consider logging the error with a descriptive message or removing the try-catch if onProgress is not expected to throw.

Suggested change
} catch {}
} catch (error) {
console.error("Error in onProgress callback at initial progress:", error);
}

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

@theabhishekbhujang please resolve the comment

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Hey @theabhishekbhujang! Just checking in - are you still working on this PR? We noticed there are some comments that may need addressing. If you need more time, no problem! Just let us know. If we don't hear back within a week, we'll close this to keep the repo tidy, but you can always reopen when ready.

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