mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-20 21:29:08 +00:00
[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:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user