diff --git a/RaygunCore.AspNetCore/Services/RaygunMiddleware.cs b/RaygunCore.AspNetCore/Services/RaygunMiddleware.cs index ff2067e..6e51d9c 100755 --- a/RaygunCore.AspNetCore/Services/RaygunMiddleware.cs +++ b/RaygunCore.AspNetCore/Services/RaygunMiddleware.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; namespace RaygunCore.Services { @@ -26,7 +27,9 @@ public async Task Invoke(HttpContext httpContext) catch (Exception ex) { var client = httpContext.RequestServices.GetRequiredService(); - await client.SendAsync(ex, RaygunSeverity.Critical); + var opt = httpContext.RequestServices.GetRequiredService>().Value; + if (!opt.IgnoreCanceledErrors || !(ex is OperationCanceledException)) + await client.SendAsync(ex, RaygunSeverity.Critical); throw; } } diff --git a/RaygunCore.props b/RaygunCore.props index a6516a4..3c8c2cc 100644 --- a/RaygunCore.props +++ b/RaygunCore.props @@ -6,7 +6,7 @@ https://github.com/anfomin/rayguncore https://github.com/anfomin/rayguncore https://github.com/anfomin/rayguncore/blob/master/LICENSE - 1.0.2 + 1.1.0 $(VERSION_SUFFIX) $(NoWarn);1573;1591 true diff --git a/RaygunCore/RaygunOptions.cs b/RaygunCore/RaygunOptions.cs index 3c632aa..6e1eaac 100755 --- a/RaygunCore/RaygunOptions.cs +++ b/RaygunCore/RaygunOptions.cs @@ -47,6 +47,12 @@ public class RaygunOptions /// public bool IgnoreLocalErrors { get; set; } + /// + /// Gets or sets if is ignored in HTTP middleware. + /// Default true. + /// + public bool IgnoreCanceledErrors { get; set; } = true; + /// /// Gets or sets if request headers are not logged. /// Works only when Raygun HTTP services registered. diff --git a/RaygunCore/ServiceExtensions.cs b/RaygunCore/ServiceExtensions.cs index 51005e0..e870750 100644 --- a/RaygunCore/ServiceExtensions.cs +++ b/RaygunCore/ServiceExtensions.cs @@ -16,6 +16,7 @@ public static class RaygunServiceExtensions /// public static IRaygunBuilder AddRaygun(this IServiceCollection services) { + services.AddOptions(); services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddEnumerable(ServiceDescriptor.Singleton());