Fixed missing SearchdomainAlreadyExistsException in SearchdomainManager

This commit is contained in:
2025-12-13 17:09:40 +01:00
parent 09d709966b
commit b7761479c8
2 changed files with 5 additions and 1 deletions

View File

@@ -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.") { }

View File

@@ -2,6 +2,7 @@ using MySql.Data.MySqlClient;
using System.Data.Common; using System.Data.Common;
using Server.Migrations; using Server.Migrations;
using Server.Helper; using Server.Helper;
using Server.Exceptions;
namespace Server; namespace Server;
@@ -86,7 +87,7 @@ public class SearchdomainManager
if (searchdomains.TryGetValue(searchdomain, out Searchdomain? value)) if (searchdomains.TryGetValue(searchdomain, out Searchdomain? value))
{ {
_logger.LogError("Searchdomain {searchdomain} could not be created, as it already exists", [searchdomain]); _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<string, dynamic> parameters = new() Dictionary<string, dynamic> parameters = new()
{ {