commit aaaa8ae06bbf6f595fc50966cfcd0d6481544c86
parent a082eb2f4b3cd31185490dc6bf197a2c80d95efa
Author: Dominik Schmidt <das1993@hotmail.com>
Date: Wed, 5 Dec 2018 10:52:59 +0100
Introduce a flag to determine whether the command engine should handle exceptions
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/bastlibridge/command.d b/src/bastlibridge/command.d
@@ -31,7 +31,7 @@ struct CommandMachine{
return cast(bool)(name in commands);
}
- void execute(in char[] name, Message m, in char[] args)
+ void execute(in char[] name, Message m, in char[] args, bool handleErrors=true)
in{
assert(name);
assert(m);
@@ -45,8 +45,13 @@ struct CommandMachine{
cmd.func(m, args);
}
catch(Exception e){
- m.respond(e.msg);
- warning(e.toString);
+ if(handleErrors){
+ m.respond(e.msg);
+ warning(e.toString);
+ }
+ else{
+ throw e;
+ }
}
}