mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-16 04:21:49 +00:00
merged exceptions for setup steps to one common exception, which contains the concrete exception
added exception handling for incorrect mod mail category id
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
package dev.sheldan.abstracto.modmail.setup;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||||
|
import dev.sheldan.abstracto.templating.Templatable;
|
||||||
|
|
||||||
|
public class InvalidCategoryException extends AbstractoRunTimeException implements Templatable {
|
||||||
|
public InvalidCategoryException() {
|
||||||
|
super("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplateName() {
|
||||||
|
return "setup_category_not_valid_exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getTemplateModel() {
|
||||||
|
return new Object();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -109,7 +109,7 @@ public class ModMailCategorySetupBean implements ModMailCategorySetup {
|
|||||||
.delayedActionConfigList(delayedSteps)
|
.delayedActionConfigList(delayedSteps)
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
throw new AbstractoRunTimeException("Category id does not conform.");
|
throw new InvalidCategoryException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ public class ModMailCategorySetupBean implements ModMailCategorySetup {
|
|||||||
future.complete(result);
|
future.complete(result);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to handle post target step.", e);
|
log.error("Failed to handle post target step.", e);
|
||||||
future.completeExceptionally(e);
|
future.completeExceptionally(new SetupStepException(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
interactiveService.createMessageWithResponse(messageText, aUserInAServer, channel.get(), parameter.getPreviousMessageId(), configAction, finalAction);
|
interactiveService.createMessageWithResponse(messageText, aUserInAServer, channel.get(), parameter.getPreviousMessageId(), configAction, finalAction);
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<#include "setup_category_not_valid_exception_message">
|
||||||
@@ -105,7 +105,7 @@ public class PostTargetSetupStep extends AbstractConfigSetupStep {
|
|||||||
future.complete(result);
|
future.complete(result);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to handle post target step.", e);
|
log.error("Failed to handle post target step.", e);
|
||||||
future.completeExceptionally(new PostTargetStepException(e));
|
future.completeExceptionally(new SetupStepException(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
interactiveService.createMessageWithResponse(messageText, aUserInAServer, channel.get(), parameter.getPreviousMessageId(), configAction, finalAction);
|
interactiveService.createMessageWithResponse(messageText, aUserInAServer, channel.get(), parameter.getPreviousMessageId(), configAction, finalAction);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class SystemConfigSetupStep extends AbstractConfigSetupStep {
|
|||||||
future.complete(result);
|
future.complete(result);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to handle system config. Retrying..", e);
|
log.warn("Failed to handle system config. Retrying..", e);
|
||||||
future.completeExceptionally(new SystemConfigStepException(e));
|
future.completeExceptionally(new SetupStepException(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
interactiveService.createMessageWithResponse(messageText, aUserInAServer, channel.get(), parameter.getPreviousMessageId(), configAction, finalAction);
|
interactiveService.createMessageWithResponse(messageText, aUserInAServer, channel.get(), parameter.getPreviousMessageId(), configAction, finalAction);
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package dev.sheldan.abstracto.core.interactive;
|
|
||||||
|
|
||||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
|
||||||
import dev.sheldan.abstracto.templating.Templatable;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class SystemConfigStepException extends AbstractoRunTimeException implements Templatable {
|
|
||||||
|
|
||||||
|
|
||||||
public SystemConfigStepException(Throwable cause) {
|
|
||||||
super("", cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTemplateName() {
|
|
||||||
return "setup_system_config_exception";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getTemplateModel() {
|
|
||||||
HashMap<String, String> stringStringHashMap = new HashMap<>();
|
|
||||||
stringStringHashMap.put("message", getCause().getMessage());
|
|
||||||
|
|
||||||
return stringStringHashMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +1 @@
|
|||||||
<#assign text><#if templateKey?has_content><#assign exceptionModel=templateModel><#include "${templateKey}"><#else>${message}</#if></#assign><#include "setup_post_target_exception_text">
|
<#assign text><#if templateKey?has_content><#assign exceptionModel=templateModel><#include "${templateKey}"><#else>${message}</#if></#assign><#include "setup_step_exception_message">
|
||||||
@@ -1 +0,0 @@
|
|||||||
<#include "setup_system_config_exception_text">
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package dev.sheldan.abstracto.core.exception;
|
|
||||||
|
|
||||||
import dev.sheldan.abstracto.templating.Templatable;
|
|
||||||
|
|
||||||
public class SetupStepException extends AbstractoRunTimeException implements Templatable {
|
|
||||||
public SetupStepException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTemplateName() {
|
|
||||||
return "setup_configuration_timeout";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getTemplateModel() {
|
|
||||||
return new Object();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,14 +5,14 @@ import dev.sheldan.abstracto.templating.Templatable;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class PostTargetStepException extends AbstractoRunTimeException implements Templatable {
|
public class SetupStepException extends AbstractoRunTimeException implements Templatable {
|
||||||
public PostTargetStepException(Throwable cause) {
|
public SetupStepException(Throwable throwable) {
|
||||||
super("", cause);
|
super("", throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTemplateName() {
|
public String getTemplateName() {
|
||||||
return "setup_post_target_exception";
|
return "setup_step_exception";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1 +0,0 @@
|
|||||||
Failed to configure post target: ${text}
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Failed to execute wizard step: ${text}
|
||||||
@@ -1 +0,0 @@
|
|||||||
Failed to configure system config: ${message}.
|
|
||||||
@@ -1 +1 @@
|
|||||||
The ID of the category you want to create the mod mail threads in. Currently: ${categoryName}
|
The ID of the category you want to create the mod mail threads in. Currently the used category is: ${categoryName}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
The provided category ID is not valid.
|
||||||
Reference in New Issue
Block a user