refactor: return CataloggerError as Results instead of throwing in commands
This commit is contained in:
parent
84c3b42874
commit
8a4e3ff184
11 changed files with 57 additions and 36 deletions
|
|
@ -45,7 +45,7 @@ public class KeyRoleCommands(
|
|||
{
|
||||
var (_, guildId) = contextInjection.GetUserAndGuild();
|
||||
if (!guildCache.TryGet(guildId, out var guild))
|
||||
throw new CataloggerError("Guild not in cache");
|
||||
return CataloggerError.Result("Guild not in cache");
|
||||
var guildRoles = roleCache.GuildRoles(guildId).ToList();
|
||||
var guildConfig = await guildRepository.GetAsync(guildId);
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ public class KeyRoleCommands(
|
|||
var (_, guildId) = contextInjection.GetUserAndGuild();
|
||||
var role = roleCache.GuildRoles(guildId).FirstOrDefault(r => r.ID == roleId);
|
||||
if (role == null)
|
||||
throw new CataloggerError("Role is not cached");
|
||||
return CataloggerError.Result("Role is not cached");
|
||||
|
||||
var guildConfig = await guildRepository.GetAsync(guildId);
|
||||
if (guildConfig.KeyRoles.Any(id => role.ID.Value == id))
|
||||
|
|
@ -111,7 +111,7 @@ public class KeyRoleCommands(
|
|||
var (_, guildId) = contextInjection.GetUserAndGuild();
|
||||
var role = roleCache.GuildRoles(guildId).FirstOrDefault(r => r.ID == roleId);
|
||||
if (role == null)
|
||||
throw new CataloggerError("Role is not cached");
|
||||
return CataloggerError.Result("Role is not cached");
|
||||
|
||||
var guildConfig = await guildRepository.GetAsync(guildId);
|
||||
if (guildConfig.KeyRoles.All(id => role.ID != id))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue