From 97d2a18aad84fb12c4e86088daa24864cef88ce8 Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Fri, 7 Oct 2022 03:16:58 +0530 Subject: [PATCH] caught translate exception fixes the translate crash --- lib/event_ds.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/event_ds.dart b/lib/event_ds.dart index d306979..b47a9f7 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -208,7 +208,11 @@ class EventData { if( translator != null) { try { translator?.translate(content, to: 'en') - .then( (result) => { evaluatedContent = "$evaluatedContent\n\nTranslation: ${result.toString()}" , if( gDebug > 0) print("Google translate returned successfully for one call.")} + .then( (result) => { evaluatedContent = "$evaluatedContent\n\nTranslation: ${result.toString()}" , if( gDebug > 0) print("Google translate returned successfully for one call.")} ) + .onError((error, stackTrace) { + if( gDebug > 0) print("Translate error = $error\n for content = $content\n"); + return {} ; + } ); } on Exception catch(err) { if( gDebug >= 0) print("Info: Error in trying to use google translate: $err");