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:
Sheldan
2020-05-26 11:48:12 +02:00
parent 158d957eee
commit a682428028
15 changed files with 33 additions and 59 deletions

View File

@@ -105,7 +105,7 @@ public class PostTargetSetupStep extends AbstractConfigSetupStep {
future.complete(result);
} catch (Exception 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);

View File

@@ -1,30 +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 PostTargetStepException extends AbstractoRunTimeException implements Templatable {
public PostTargetStepException(Throwable cause) {
super("", cause);
}
@Override
public String getTemplateName() {
return "setup_post_target_exception";
}
@Override
public Object getTemplateModel() {
HashMap<String, Object> stringStringHashMap = new HashMap<>();
if(getCause() instanceof Templatable) {
Templatable templatable = (Templatable) getCause();
stringStringHashMap.put("templateKey", templatable.getTemplateName());
stringStringHashMap.put("templateModel", templatable.getTemplateModel());
}
stringStringHashMap.put("message", getCause().getMessage());
return stringStringHashMap;
}
}

View File

@@ -95,7 +95,7 @@ public class SystemConfigSetupStep extends AbstractConfigSetupStep {
future.complete(result);
} catch (Exception 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);

View File

@@ -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;
}
}

View File

@@ -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">