mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-24 13:44:33 +00:00
moved some more exceptions to templates
made more specific exceptions for certain cases
This commit is contained in:
@@ -59,7 +59,7 @@ public class BotServiceBean implements BotService {
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new GuildException(String.format(GUILD_NOT_FOUND, serverId));
|
||||
throw new GuildException(serverId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class BotServiceBean implements BotService {
|
||||
if(guildById != null) {
|
||||
return guildById.getMemberById(memberId);
|
||||
} else {
|
||||
throw new GuildException(String.format(GUILD_NOT_FOUND, serverId));
|
||||
throw new GuildException(serverId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class BotServiceBean implements BotService {
|
||||
if(guildById != null) {
|
||||
return isUserInGuild(guildById, aUserInAServer);
|
||||
} else {
|
||||
throw new GuildException(String.format(GUILD_NOT_FOUND, aUserInAServer.getServerReference().getId()));
|
||||
throw new GuildException(aUserInAServer.getServerReference().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class BotServiceBean implements BotService {
|
||||
Emote emoteById = guild.getEmoteById(emote.getEmoteId());
|
||||
return Optional.ofNullable(emoteById);
|
||||
}
|
||||
throw new GuildException(String.format(GUILD_NOT_FOUND, serverId));
|
||||
throw new GuildException(serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,7 +147,7 @@ public class BotServiceBean implements BotService {
|
||||
Guild guild = guildOptional.get();
|
||||
return Optional.ofNullable(guild.getTextChannelById(textChannelId));
|
||||
}
|
||||
throw new GuildException(String.format(GUILD_NOT_FOUND, serverId));
|
||||
throw new GuildException(GUILD_NOT_FOUND, serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.exception.CategoryNotFoundException;
|
||||
import dev.sheldan.abstracto.core.exception.ChannelNotFoundException;
|
||||
import dev.sheldan.abstracto.core.exception.GuildException;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
@@ -53,7 +54,7 @@ public class ChannelServiceBean implements ChannelService {
|
||||
}
|
||||
} else {
|
||||
log.error("Guild {} was not found when trying to post a message", channel.getServer().getId());
|
||||
throw new GuildException(String.format("Guild %s to post in channel %s was not found.", channel.getServer().getId(), channel.getId()));
|
||||
throw new GuildException(channel.getServer().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ public class ChannelServiceBean implements ChannelService {
|
||||
}
|
||||
} else {
|
||||
log.error("Guild {} was not found when trying to post a message", channel.getServer().getId());
|
||||
throw new GuildException(String.format("Guild %s to post in channel %s was not found.", channel.getServer().getId(), channel.getId()));
|
||||
throw new GuildException(channel.getServer().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,12 +196,8 @@ public class ChannelServiceBean implements ChannelService {
|
||||
if(categoryById != null) {
|
||||
return categoryById.createTextChannel(name).submit();
|
||||
}
|
||||
CompletableFuture<TextChannel> objectCompletableFuture = new CompletableFuture<>();
|
||||
objectCompletableFuture.completeExceptionally(new AbstractoRunTimeException("Mod mail category is not setup."));
|
||||
return objectCompletableFuture;
|
||||
throw new CategoryNotFoundException(categoryId, server.getId());
|
||||
}
|
||||
CompletableFuture<TextChannel> objectCompletableFuture = new CompletableFuture<>();
|
||||
objectCompletableFuture.completeExceptionally(new AbstractoRunTimeException("Guild to create mod mail channel for was not found."));
|
||||
return objectCompletableFuture;
|
||||
throw new GuildException(server.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +104,7 @@ public class MessageCacheBean implements MessageCache {
|
||||
}
|
||||
} else {
|
||||
log.error("Not able to load message {} in channel {} in guild {}. Guild not found.", messageId, textChannelId, guildId);
|
||||
future.completeExceptionally(new GuildException(String.format("Not able to load message %s. Guild %s not found.", messageId, guildId)));
|
||||
|
||||
future.completeExceptionally(new GuildException(guildId));
|
||||
}
|
||||
|
||||
return future;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class MessageServiceBean implements MessageService {
|
||||
message.addReaction(defaultEmote).queue();}
|
||||
} else {
|
||||
log.error("Cannot add reaction, guild not found {}", serverId);
|
||||
throw new GuildException(String.format("Cannot add reaction, guild %s not found.", serverId));
|
||||
throw new GuildException(serverId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class PostTargetServiceBean implements PostTargetService {
|
||||
throw new ChannelNotFoundException(target.getChannelReference().getId(), target.getServerReference().getId());
|
||||
}
|
||||
} else {
|
||||
throw new GuildException(String.format("Incorrect post target configuration. Guild %s cannot be found.", target.getServerReference().getId()));
|
||||
throw new GuildException(target.getServerReference().getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RoleServiceBean implements RoleService {
|
||||
throw new RoleNotFoundInGuildException(role.getId(), aUserInAServer.getServerReference().getId());
|
||||
}
|
||||
} else {
|
||||
throw new GuildException(String.format("Failed to load guild %s.", aUserInAServer.getServerReference().getId()));
|
||||
throw new GuildException(aUserInAServer.getServerReference().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class RoleServiceBean implements RoleService {
|
||||
throw new RoleNotFoundInGuildException(role.getId(), aUserInAServer.getServerReference().getId());
|
||||
}
|
||||
} else {
|
||||
throw new GuildException(String.format("Failed to load guild %s.", aUserInAServer.getServerReference().getId()));
|
||||
throw new GuildException(aUserInAServer.getServerReference().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class RoleServiceBean implements RoleService {
|
||||
if(guildById.isPresent()) {
|
||||
return guildById.get().getRoleById(role.getId());
|
||||
} else {
|
||||
throw new GuildException(String.format("Failed to load guild %s.", role.getServer().getId()));
|
||||
throw new GuildException(role.getServer().getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.core.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.exception.GuildException;
|
||||
import dev.sheldan.abstracto.core.models.database.*;
|
||||
import dev.sheldan.abstracto.core.repository.ServerRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -53,7 +53,7 @@ public class ServerManagementServiceBean implements ServerManagementService {
|
||||
log.info("Adding user {} to server {}", userId, serverId);
|
||||
Optional<AServer> server = repository.findById(serverId);
|
||||
AUser user = userManagementService.loadUser(userId);
|
||||
AServer serverReference = server.orElseThrow(() -> new AbstractoRunTimeException(String.format("Cannnot find server %s", serverId)));
|
||||
AServer serverReference = server.orElseThrow(() -> new GuildException(serverId));
|
||||
AUserInAServer aUserInAServer = AUserInAServer.builder().serverReference(serverReference).userReference(user).build();
|
||||
serverReference.getUsers().add(aUserInAServer);
|
||||
return aUserInAServer;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<#include "duration_invalid_time_format_exception_text">
|
||||
Reference in New Issue
Block a user