From ab9084b23a77e5f271f4dfaef5584e1976fb3f8a Mon Sep 17 00:00:00 2001 From: David Fenster Date: Fri, 20 Mar 2026 15:46:47 -0400 Subject: [PATCH 1/2] fix a bug that results in empty translation aggregate exceptions could be caused by a single request failing. the error is swallowed by a catch and results in an empty string translation. instead this fix will not use an empty string, enabling the user to retry the translation. --- ...LMtTranslationProviderLanguageDirection.cs | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/DeepL Translation Provider/Sdl.Community.DeelLMTProvider/Studio/DeepLMtTranslationProviderLanguageDirection.cs b/DeepL Translation Provider/Sdl.Community.DeelLMTProvider/Studio/DeepLMtTranslationProviderLanguageDirection.cs index fc647a537e..048c446e72 100644 --- a/DeepL Translation Provider/Sdl.Community.DeelLMTProvider/Studio/DeepLMtTranslationProviderLanguageDirection.cs +++ b/DeepL Translation Provider/Sdl.Community.DeelLMTProvider/Studio/DeepLMtTranslationProviderLanguageDirection.cs @@ -240,39 +240,30 @@ private string LookupDeepL(string sourceText) => private List TranslateSegments(List preTranslateSegments) { - try + foreach (var segment in preTranslateSegments.Where(segment => segment != null)) { - foreach (var segment in preTranslateSegments.Where(segment => segment != null)) - { - var newSeg = segment.TranslationUnit.SourceSegment.Duplicate(); - - var sourceText = ApplyBeforeTranslationSettings(newSeg); + var newSeg = segment.TranslationUnit.SourceSegment.Duplicate(); + var sourceText = ApplyBeforeTranslationSettings(newSeg); + segment.SourceText = sourceText; + } - segment.SourceText = sourceText; - } + Parallel.ForEach(preTranslateSegments, segment => + { + if (segment == null) return; - Parallel.ForEach(preTranslateSegments, segment => + if (_options.ResendDraft || + segment.TranslationUnit.ConfirmationLevel == ConfirmationLevel.Unspecified) { - if (segment == null) return; - - if (_options.ResendDraft || - segment.TranslationUnit.ConfirmationLevel == ConfirmationLevel.Unspecified) + try { segment.PlainTranslation = LookupDeepL(segment.SourceText); } - }); - - return preTranslateSegments; - } - catch (AggregateException e) - { - foreach (var innerEx in e.InnerExceptions) _logger.Error($"{innerEx.Message}\n {innerEx.StackTrace}"); - throw new Exception(e.InnerExceptions[0].Message); - } - catch (Exception e) - { - _logger.Error($"{e.Message}\n {e.StackTrace}"); - } + catch (Exception ex) + { + _logger.Error($"{ex.Message}\n {ex.StackTrace}"); + } + } + }); return preTranslateSegments; } From c56aaa5a794d282be855f96555962286795077f3 Mon Sep 17 00:00:00 2001 From: David Fenster Date: Fri, 20 Mar 2026 15:59:44 -0400 Subject: [PATCH 2/2] dont swallow the exception --- .../Client/DeepLTranslationProviderClient.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DeepL Translation Provider/Sdl.Community.DeelLMTProvider/Client/DeepLTranslationProviderClient.cs b/DeepL Translation Provider/Sdl.Community.DeelLMTProvider/Client/DeepLTranslationProviderClient.cs index a7e05a66cc..6930947b58 100644 --- a/DeepL Translation Provider/Sdl.Community.DeelLMTProvider/Client/DeepLTranslationProviderClient.cs +++ b/DeepL Translation Provider/Sdl.Community.DeelLMTProvider/Client/DeepLTranslationProviderClient.cs @@ -197,6 +197,8 @@ public string Translate(LanguagePair languageDirection, string sourceText, DeepL { Logger.Error(innerEx); } + + throw; } catch (Exception ex) {