From 634d55fdd771f508f40796e539e1075942d682e1 Mon Sep 17 00:00:00 2001 From: Andrey Ioch Date: Tue, 5 Dec 2023 19:30:04 +0300 Subject: [PATCH] Cancellation exception handling --- src/Misc/Curiosity.Tools.Web/CHANGELOG.md | 6 ++++++ .../Curiosity.Tools.Web/Controllers/MVCBaseController.cs | 6 ++++++ src/Misc/Curiosity.Tools.Web/Curiosity.Tools.Web.csproj | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Misc/Curiosity.Tools.Web/CHANGELOG.md b/src/Misc/Curiosity.Tools.Web/CHANGELOG.md index 765b494..1d42f92 100644 --- a/src/Misc/Curiosity.Tools.Web/CHANGELOG.md +++ b/src/Misc/Curiosity.Tools.Web/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [1.3.1] + +### Added + +- Cancellation exception handling, write a message to WARN log + ## [1.3.0] - 2023-11-28 ### Changed diff --git a/src/Misc/Curiosity.Tools.Web/Controllers/MVCBaseController.cs b/src/Misc/Curiosity.Tools.Web/Controllers/MVCBaseController.cs index dad6959..31937cd 100644 --- a/src/Misc/Curiosity.Tools.Web/Controllers/MVCBaseController.cs +++ b/src/Misc/Curiosity.Tools.Web/Controllers/MVCBaseController.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Text.Encodings.Web; +using System.Threading.Tasks; using Curiosity.Tools.Web.Resources; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Diagnostics; @@ -83,6 +84,11 @@ public ActionResult ErrorView( message = ex.Message; logger.LogWarning(ex, $"Connection was closed by the client while sending response: {ex.Message}."); break; + case TaskCanceledException _: + case OperationCanceledException _: + message = ex.Message; + logger.LogWarning(ex, "Request was canceled by user"); + break; default: logger.LogError(ex, $"Unhandled error: {ex.Message}"); break; diff --git a/src/Misc/Curiosity.Tools.Web/Curiosity.Tools.Web.csproj b/src/Misc/Curiosity.Tools.Web/Curiosity.Tools.Web.csproj index db093f9..d46ebc3 100644 --- a/src/Misc/Curiosity.Tools.Web/Curiosity.Tools.Web.csproj +++ b/src/Misc/Curiosity.Tools.Web/Curiosity.Tools.Web.csproj @@ -12,7 +12,7 @@ 1.0.0 1.0.0 - 1.3.0 + 1.3.1 Max Markelow (@markeli), Andrei Vinogradov (@anri-vin), Andrey Ioch (@DevCorvette) SIIS Ltd