From b8c10c42989e586d020584e28f0835f6abc4882d Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Tue, 27 Dec 2022 20:08:18 +0100 Subject: [PATCH] adjustments for grpc service client --- .../MareConfigurationServiceClient.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/MareSynchronosServer/MareSynchronosShared/Services/MareConfigurationServiceClient.cs b/MareSynchronosServer/MareSynchronosShared/Services/MareConfigurationServiceClient.cs index 4571e17..580fdf0 100644 --- a/MareSynchronosServer/MareSynchronosShared/Services/MareConfigurationServiceClient.cs +++ b/MareSynchronosServer/MareSynchronosShared/Services/MareConfigurationServiceClient.cs @@ -52,10 +52,26 @@ public class MareConfigurationServiceClient : IConfigurationService where if (!isCurrent) { - var result = GetValueFromGrpc(key, defaultValue, prop.PropertyType); - if (result == null) return defaultValue; - _cachedRemoteProperties[key] = result; - return (T1)_cachedRemoteProperties[key].Value; + try + { + var result = GetValueFromGrpc(key, defaultValue, prop.PropertyType); + if (result == null) return defaultValue; + _cachedRemoteProperties[key] = result; + return (T1)_cachedRemoteProperties[key].Value; + } + catch (Exception ex) + { + if (existingEntry != null) + { + _logger.LogWarning(ex, "Could not get value for {key} from Grpc, returning existing", key); + return (T1)existingEntry.Value; + } + else + { + _logger.LogWarning(ex, "Could not get value for {key} from Grpc, returning default", key); + return defaultValue; + } + } } }