mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 06:07:27 +00:00
IAction exceptions now report to script console
This commit is contained in:
1 parent
5d682962be
commit
ac223cbb53
2 files changed
+23
No files matched your search
@@ -6,6 +6,7 @@ import noppes.npcs.api.handler.data.IActionQueue;
|
||||
import noppes.npcs.api.handler.data.actions.IConditionalAction;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -344,6 +345,10 @@ public class Action implements IAction {
|
||||
try {
|
||||
onStart.accept(this);
|
||||
} catch (Throwable t) {
|
||||
String err = "IAction" + getName() + " onStart threw an exception:";
|
||||
if (reportTo != null)
|
||||
reportTo.appendConsole(err + "\n" + ExceptionUtils.getStackTrace(t));
|
||||
|
||||
manager.LOGGER.error("onStart Task of " + this + " threw an exception:", t);
|
||||
}
|
||||
|
||||
@@ -359,6 +364,11 @@ public class Action implements IAction {
|
||||
task.accept(this);
|
||||
count++;
|
||||
} catch (Throwable t) {
|
||||
String err = "IAction '" + name + "' threw an exception:";
|
||||
|
||||
if (reportTo != null)
|
||||
reportTo.appendConsole(err + "\n" + ExceptionUtils.getStackTrace(t));
|
||||
|
||||
manager.LOGGER.error("Task of " + this + " threw an exception:", t);
|
||||
markDone();
|
||||
}
|
||||
@@ -374,6 +384,10 @@ public class Action implements IAction {
|
||||
try {
|
||||
onDone.accept(this);
|
||||
} catch (Throwable t) {
|
||||
String err = "IAction" + getName() + " onDone threw an exception:";
|
||||
if (reportTo != null)
|
||||
reportTo.appendConsole(err + "\n" + ExceptionUtils.getStackTrace(t));
|
||||
|
||||
manager.LOGGER.error("onDone Task of " + this + " threw an exception:", t);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import noppes.npcs.api.handler.data.IAction;
|
||||
import noppes.npcs.api.handler.data.actions.IConditionalAction;
|
||||
import noppes.npcs.controllers.data.action.Action;
|
||||
import noppes.npcs.controllers.data.action.ActionManager;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
@@ -130,6 +131,10 @@ public class ConditionalAction extends Action implements IConditionalAction {
|
||||
count++;
|
||||
taskExecuted = true;
|
||||
} catch (Throwable t) {
|
||||
String err = "IConditionalAction '" + getName() + "' threw an exception:";
|
||||
if (reportTo != null)
|
||||
reportTo.appendConsole(err + "\n" + ExceptionUtils.getStackTrace(t));
|
||||
|
||||
manager.LOGGER.error("Task of " + this + " threw an exception:", t);
|
||||
markDone();
|
||||
}
|
||||
@@ -146,6 +151,10 @@ public class ConditionalAction extends Action implements IConditionalAction {
|
||||
try {
|
||||
onTermination.accept(this);
|
||||
} catch (Throwable t) {
|
||||
String err = "IConditionalAction" + getName() + " onTermination threw an exception:";
|
||||
if (reportTo != null)
|
||||
reportTo.appendConsole(err + "\n" + ExceptionUtils.getStackTrace(t));
|
||||
|
||||
manager.LOGGER.error("Termination Task of " + this + " threw an exception:", t);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user