From 0423dac2938c80adb7ea0e3a11da5bf1979c1e7c Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 09:57:38 +0000 Subject: [PATCH] refactor: remove unused exception variables in catch clauses This PR streamlines exception handling by removing unused exception variables from multiple catch blocks throughout the codebase. - **Variable declared when catching `Exception` is unused**: Several catch clauses declared exception variables (e.g., `ex`, `jrex`, `jsex`, `kex`, and `SqlException` variables) that were never referenced, resulting in unnecessary code and compiler warnings. Each instance has been updated to omit the variable name (for example, changing `catch(Exception ex)` to `catch(Exception)`), improving readability and adhering to best practices in exception handling. > This Autofix was generated by AI. Please review the change before merging. --- Shared.EventStore/Aggregate/DomainEventFactory.cs | 4 ++-- Shared.EventStore/Aggregate/TypeMapConvertor.cs | 2 +- Shared.IntegrationTesting/BaseDockerHelper.cs | 2 +- Shared/Extensions/StringExtensions.cs | 4 ++-- Shared/General/ConfigurationReader.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Shared.EventStore/Aggregate/DomainEventFactory.cs b/Shared.EventStore/Aggregate/DomainEventFactory.cs index f07cd79..229b258 100644 --- a/Shared.EventStore/Aggregate/DomainEventFactory.cs +++ b/Shared.EventStore/Aggregate/DomainEventFactory.cs @@ -54,8 +54,8 @@ public DomainEvent CreateDomainEvent(Guid aggregateId, ResolvedEvent @event) try{ eventType = TypeMap.GetType(@event.Event.EventType); } - catch(Exception ex){ - // Nothing here + catch(Exception) + { } if (eventType == null) diff --git a/Shared.EventStore/Aggregate/TypeMapConvertor.cs b/Shared.EventStore/Aggregate/TypeMapConvertor.cs index 9deef1e..839ae4f 100644 --- a/Shared.EventStore/Aggregate/TypeMapConvertor.cs +++ b/Shared.EventStore/Aggregate/TypeMapConvertor.cs @@ -39,7 +39,7 @@ public static IDomainEvent Convertor(Guid aggregateId, ResolvedEvent @event) { eventType = TypeMap.GetType(@event.Event.EventType); } - catch (Exception ex) + catch (Exception) { // Nothing here } diff --git a/Shared.IntegrationTesting/BaseDockerHelper.cs b/Shared.IntegrationTesting/BaseDockerHelper.cs index cb9d59b..80aad80 100644 --- a/Shared.IntegrationTesting/BaseDockerHelper.cs +++ b/Shared.IntegrationTesting/BaseDockerHelper.cs @@ -671,7 +671,7 @@ protected void CheckSqlConnection(IContainerService databaseServerContainer){ connection.Close(); this.Trace("SQL Server Container Running"); } - catch(SqlException ex){ + catch(SqlException){ if (connection.State == ConnectionState.Open){ connection.Close(); } diff --git a/Shared/Extensions/StringExtensions.cs b/Shared/Extensions/StringExtensions.cs index 0d1da42..b178319 100644 --- a/Shared/Extensions/StringExtensions.cs +++ b/Shared/Extensions/StringExtensions.cs @@ -26,12 +26,12 @@ public static Boolean TryParseJson(this String obj, out T result) result = JsonConvert.DeserializeObject(obj, settings); return true; } - catch (JsonReaderException jrex) + catch (JsonReaderException) { result = default(T); return false; } - catch (JsonSerializationException jsex) + catch (JsonSerializationException) { result = default(T); return false; diff --git a/Shared/General/ConfigurationReader.cs b/Shared/General/ConfigurationReader.cs index 420c73b..3042c18 100644 --- a/Shared/General/ConfigurationReader.cs +++ b/Shared/General/ConfigurationReader.cs @@ -88,7 +88,7 @@ public static T GetValueOrDefault(String sectionName, String keyName, T defau return (T)Convert.ChangeType(value, typeof(T)); } - catch (KeyNotFoundException kex) + catch (KeyNotFoundException) { return defaultValue; }