aboutsummaryrefslogtreecommitdiff
path: root/plugins/VNLib.Data.Caching.Providers.VNCache
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-03-09 19:13:21 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2024-03-09 19:13:21 -0500
commit5d4192880654fd6e00e587814169415b42621327 (patch)
treef35e2e41e346c5067f0195e7b0f7197e9729e940 /plugins/VNLib.Data.Caching.Providers.VNCache
parenta4b3504bb891829074d1efde0433eae010862181 (diff)
chore: #2 Minor fixes and polish before release
Diffstat (limited to 'plugins/VNLib.Data.Caching.Providers.VNCache')
-rw-r--r--plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs37
1 files changed, 35 insertions, 2 deletions
diff --git a/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs b/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs
index a8f86f9..e87d430 100644
--- a/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs
+++ b/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs
@@ -404,9 +404,42 @@ namespace VNLib.Data.Caching.Providers.VNCache
private sealed record class DiscoveryErrHAndler(ILogProvider Logger) : ICacheDiscoveryErrorHandler
{
- public void OnDiscoveryError(CacheNodeAdvertisment errorNode, Exception ex)
+ public void OnDiscoveryError(CacheNodeAdvertisment errorNode, Exception ex)
+ => OnDiscoveryError(errorNode, ex);
+
+ public void OnDiscoveryError(Uri errorAddress, Exception ex)
+ => OnDiscoveryError(ex, null, errorAddress);
+
+ public void OnDiscoveryError(Exception ex, CacheNodeAdvertisment? errorNode, Uri? address)
{
- Logger.Error("Failed to discover nodes from server {s} cause:\n{err}", errorNode?.NodeId, ex);
+ string node = errorNode?.NodeId ?? address?.ToString() ?? "unknown";
+
+ if(ex is HttpRequestException he)
+ {
+ if(he.InnerException is SocketException se)
+ {
+ LogErrorException(se);
+ return;
+ }
+
+ LogErrorException(he);
+ return;
+ }
+
+ LogErrorException(ex);
+ return;
+
+ void LogErrorException(Exception ex)
+ {
+ if(Logger.IsEnabled(LogLevel.Debug))
+ {
+ Logger.Error("Failed to discover nodes from server {s} cause:\n{err}", node, ex);
+ }
+ else
+ {
+ Logger.Error("Failed to discover nodes from server {s} cause:\n{err}", node, ex.Message);
+ }
+ }
}
}
}