[AB-xxx] adding generic input format exception handling

adding level_action to send a message to a channel once a level is reached
This commit is contained in:
Sheldan
2024-07-27 19:51:49 +02:00
parent b258a8bc54
commit 65e956827c
7 changed files with 169 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
package dev.sheldan.abstracto.core.exception;
import dev.sheldan.abstracto.core.models.exception.InputFormatExceptionModel;
import dev.sheldan.abstracto.core.templating.Templatable;
public class InputFormatException extends AbstractoRunTimeException implements Templatable {
private final InputFormatExceptionModel model;
public InputFormatException(String wrongFormat, String validFormat) {
super("Input format exception ");
this.model = InputFormatExceptionModel
.builder()
.invalidFormat(wrongFormat)
.validFormat(validFormat)
.build();
}
@Override
public String getTemplateName() {
return "input_invalid_format_exception";
}
@Override
public Object getTemplateModel() {
return model;
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.abstracto.core.models.exception;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Setter
@Getter
@Builder
public class InputFormatExceptionModel implements Serializable {
private final String invalidFormat;
private final String validFormat;
}

View File

@@ -102,7 +102,7 @@ public class ParseUtils {
throw new AbstractoTemplatedException("No channel found with name.", "no_channel_found_by_name_exception");
}
if(potentialMatches.size() > 1) {
throw new AbstractoTemplatedException("Multiple channels found..", "multiple_channels_found_by_name_exception");
throw new AbstractoTemplatedException("Multiple channels found.", "multiple_channels_found_by_name_exception");
}
return guild.getGuildChannelById(potentialMatches.get(0).getId());
}