From e01db9da107b06eae2a61de79193f9081a6c76e7 Mon Sep 17 00:00:00 2001 From: Daniel Hindrikes Date: Thu, 3 Oct 2024 10:51:16 +0200 Subject: [PATCH] Added second constructor to InsightsMessageHandler --- TinyInsights/InsightsMessageHandler.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/TinyInsights/InsightsMessageHandler.cs b/TinyInsights/InsightsMessageHandler.cs index 59a60fd..2a03054 100644 --- a/TinyInsights/InsightsMessageHandler.cs +++ b/TinyInsights/InsightsMessageHandler.cs @@ -11,6 +11,16 @@ public InsightsMessageHandler(IInsights insights) InnerHandler = new HttpClientHandler(); } + public InsightsMessageHandler(IInsights insights, DelegatingHandler? innerHandler) + { + this.insights = insights; + + if (innerHandler is not null) + { + InnerHandler = innerHandler; + } + } + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { var startTime = DateTime.Now; @@ -27,7 +37,7 @@ protected override async Task SendAsync(HttpRequestMessage { response.EnsureSuccessStatusCode(); } - catch(Exception e) + catch (Exception e) { exception = e; } @@ -45,7 +55,7 @@ await insights.TrackDependencyAsync( return response; } - catch(Exception ex) + catch (Exception ex) { var endTime = DateTime.Now; await insights.TrackDependencyAsync(