From b7761479c84848d3aacfa23fd3d477813dbc8af6 Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sat, 13 Dec 2025 17:09:40 +0100 Subject: [PATCH] Fixed missing SearchdomainAlreadyExistsException in SearchdomainManager --- src/Server/Exceptions/SearchdomainExceptions.cs | 3 +++ src/Server/SearchdomainManager.cs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 src/Server/Exceptions/SearchdomainExceptions.cs diff --git a/src/Server/Exceptions/SearchdomainExceptions.cs b/src/Server/Exceptions/SearchdomainExceptions.cs new file mode 100644 index 0000000..84e8b1c --- /dev/null +++ b/src/Server/Exceptions/SearchdomainExceptions.cs @@ -0,0 +1,3 @@ +namespace Server.Exceptions; +public class SearchdomainNotFoundException(string searchdomainName) : Exception($"Searchdomain with name {searchdomainName} not found.") { } +public class SearchdomainAlreadyExistsException(string searchdomainName) : Exception($"Searchdomain with name {searchdomainName} already exists.") { } \ No newline at end of file diff --git a/src/Server/SearchdomainManager.cs b/src/Server/SearchdomainManager.cs index d5670c0..9b87b8a 100644 --- a/src/Server/SearchdomainManager.cs +++ b/src/Server/SearchdomainManager.cs @@ -2,6 +2,7 @@ using MySql.Data.MySqlClient; using System.Data.Common; using Server.Migrations; using Server.Helper; +using Server.Exceptions; namespace Server; @@ -86,7 +87,7 @@ public class SearchdomainManager if (searchdomains.TryGetValue(searchdomain, out Searchdomain? value)) { _logger.LogError("Searchdomain {searchdomain} could not be created, as it already exists", [searchdomain]); - throw new Exception("Searchdomain already exists"); // TODO create proper SearchdomainAlreadyExists exception + throw new SearchdomainAlreadyExistsException(searchdomain); } Dictionary parameters = new() {