@@ -52,16 +52,12 @@ public IEnumerable<string> GetAvailableLanguages()
5252 . Select ( x => x . Language )
5353 . ToArray ( ) ;
5454 }
55- catch ( LocalizerException )
56- {
57- throw ;
58- }
5955 catch ( Exception exception )
6056 {
61- ThrowLocalizerException ( exception , "Failed to get available languages." ) ;
57+ FailedToGetAvailableLanguagesException localizerException = new ( innerException : exception ) ;
58+ Logger . LogError ( localizerException , localizerException . Message ) ;
59+ throw localizerException ;
6260 }
63-
64- return Array . Empty < string > ( ) ;
6561 }
6662
6763 public string GetCurrentLanguage ( ) => CurrentDictionary . Language ;
@@ -89,11 +85,10 @@ public async Task SetLanguage(string language)
8985 }
9086 catch ( Exception exception )
9187 {
92- ThrowLocalizerException ( exception , "Exception setting language. [{PreviousLanguage} -> {NextLanguage}]" , previousLanguage , language ) ;
88+ FailedToSetLanguageException localizerException = new ( previousLanguage , language , message : string . Empty , innerException : exception ) ;
89+ Logger . LogError ( localizerException , localizerException . Message ) ;
90+ throw localizerException ;
9391 }
94-
95- ThrowLocalizerException ( innerException : null , "Failed to set language. [{PreviousLanguage} -> {NextLanguage}]" , previousLanguage , language ) ;
96- return ;
9792 }
9893
9994 public string GetLocalizedString ( string uid )
@@ -111,9 +106,15 @@ public string GetLocalizedString(string uid)
111106 return item . Value ;
112107 }
113108 }
109+ catch ( LocalizerException )
110+ {
111+ throw ;
112+ }
114113 catch ( Exception exception )
115114 {
116- ThrowLocalizerException ( exception , "Failed to get localized string. [Uid: {Uid}]" , uid ) ;
115+ FailedToGetLocalizedStringException localizerException = new ( uid , innerException : exception ) ;
116+ Logger . LogError ( localizerException , localizerException . Message ) ;
117+ throw localizerException ;
117118 }
118119
119120 return this . options . UseUidWhenLocalizedStringNotFound is true
@@ -135,9 +136,15 @@ public IEnumerable<string> GetLocalizedStrings(string uid)
135136 return items . Select ( x => x . Value ) ;
136137 }
137138 }
139+ catch ( LocalizerException )
140+ {
141+ throw ;
142+ }
138143 catch ( Exception exception )
139144 {
140- ThrowLocalizerException ( exception , "Failed to get localized string. [Uid: {Uid}]" , uid ) ;
145+ FailedToGetLocalizedStringException localizerException = new ( uid , innerException : exception ) ;
146+ Logger . LogError ( localizerException , localizerException . Message ) ;
147+ throw localizerException ;
141148 }
142149
143150 return this . options . UseUidWhenLocalizedStringNotFound is true
@@ -228,13 +235,6 @@ private static void DependencyObjectsReferences_DependencyObjectRemoved(object?
228235 e . ItemsTotal ) ;
229236 }
230237
231- private static void ThrowLocalizerException ( Exception ? innerException , string message , params object ? [ ] args )
232- {
233- LocalizerException localizerException = new ( message , innerException ) ;
234- Logger . LogError ( localizerException , message , args ) ;
235- throw localizerException ;
236- }
237-
238238 private static DependencyProperty ? GetDependencyProperty ( DependencyObject dependencyObject , string dependencyPropertyName )
239239 {
240240 Type type = dependencyObject . GetType ( ) ;
0 commit comments