Return original exception in case retry fails as well.

This commit is contained in:
Johannes Mockenhaupt 2017-07-22 01:44:34 +02:00
parent d0d3e46e03
commit e45acab420
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -311,7 +311,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
if (!reason.toLowerCase().contains("user") if (!reason.toLowerCase().contains("user")
&& lastCmdTime.getTime() > 0 && lastCmdTime.getTime() > 0
&& System.currentTimeMillis() > lastCmdTime.getTime() + 60 * 1000) { && System.currentTimeMillis() > lastCmdTime.getTime() + 60 * 1000) {
log.debug("Not fetching state from pump, since we did already within the last 60 seconds"); log.debug("Not fetching state from pump, since we did already within the last 60 seconds");
} else { } else {
runCommand(new ReadPumpStateCommand()); runCommand(new ReadPumpStateCommand());
} }
@ -390,7 +390,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
MainApp.bus().post(new EventComboPumpUpdateGUI()); MainApp.bus().post(new EventComboPumpUpdateGUI());
CommandResult commandResult = ruffyScripter.runCommand(command); CommandResult commandResult = ruffyScripter.runCommand(command);
if (commandResult.exception != null) { if (!commandResult.success && commandResult.exception != null) {
log.error("CommandResult has exception, rebinding ruffy service", commandResult.exception); log.error("CommandResult has exception, rebinding ruffy service", commandResult.exception);
unbindRuffyService(); unbindRuffyService();
@ -400,13 +400,14 @@ public class ComboPlugin implements PluginBase, PumpInterface {
if (ruffyScripter == null) { if (ruffyScripter == null) {
log.error("Rebinding failed"); log.error("Rebinding failed");
} } else if (!commandResult.enacted && !(command instanceof BolusCommand)) {
// retry command, but make sure it wasn't enacted and don't retry
// retry command, but make sure it wasn't enacted and don't retry // bolus commands (user is interacting with AAPS right now so he can
// bolus commands (user is interacting with AAPS right now so he can // deal with it and we don't want to deliver a bolus twice)
// deal with it and we don't want to deliver a bolus twice CommandResult retriedCommandResult = ruffyScripter.runCommand(command);
if (!commandResult.enacted && !(command instanceof BolusCommand)) { if (retriedCommandResult.success) {
commandResult = ruffyScripter.runCommand(command) ; commandResult = retriedCommandResult;
}
} }
} }