mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-26 15:44:46 +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 () => {
|
||||
setUIState('loading');
|
||||
try {
|
||||
const { content, detectedSourceLanguage, provider, ...props } =
|
||||
await onTranslate(apiSourceLang.current, targetLang);
|
||||
if (content) {
|
||||
|
@ -78,6 +79,10 @@ function TranslationBlock({
|
|||
console.error(result);
|
||||
setUIState('error');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setUIState('error');
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Add table
Reference in a new issue