mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01:00
Catch the error
This commit is contained in:
parent
2ed6b80dcc
commit
23057efcca
1 changed files with 25 additions and 20 deletions
|
@ -54,6 +54,7 @@ function TranslationBlock({
|
||||||
|
|
||||||
const translate = async () => {
|
const translate = async () => {
|
||||||
setUIState('loading');
|
setUIState('loading');
|
||||||
|
try {
|
||||||
const { content, detectedSourceLanguage, provider, ...props } =
|
const { content, detectedSourceLanguage, provider, ...props } =
|
||||||
await onTranslate(apiSourceLang.current, targetLang);
|
await onTranslate(apiSourceLang.current, targetLang);
|
||||||
if (content) {
|
if (content) {
|
||||||
|
@ -78,6 +79,10 @@ function TranslationBlock({
|
||||||
console.error(result);
|
console.error(result);
|
||||||
setUIState('error');
|
setUIState('error');
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
setUIState('error');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
Loading…
Reference in a new issue