Skip to content

Commit

Permalink
chore: error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
yossydev committed Nov 17, 2024
1 parent 77d9ed5 commit 7b176b0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions app/islands/TranslatorButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ const TranslatorButton: FC<Props> = ({ content }) => {
// biome-ignore lint: lint/suspicious/noExplicitAny
"createTranslator" in (self.translation as any)
) {
// biome-ignore lint: lint/suspicious/noExplicitAny
const translator = await (self.translation as any).createTranslator({
sourceLanguage: "ja",
targetLanguage: e.target.value,
});
const res = await translator.translate(content);
console.log("res", res);
try {
// biome-ignore lint: lint/suspicious/noExplicitAny
const translator = await (self.translation as any).createTranslator({
sourceLanguage: "ja",
targetLanguage: e.target.value,
});
const res = await translator.translate(content);
console.log("res", res);
} catch (error) {
console.error("translator error", error);
}
} else {
window.alert("The Translator API is not supported");
}
Expand Down

0 comments on commit 7b176b0

Please sign in to comment.