From 3a5908ac49976634fa3c786f33300500accadc15 Mon Sep 17 00:00:00 2001 From: Hai Brenner Date: Tue, 28 Jun 2016 11:28:14 +0300 Subject: [PATCH] A cancel by the voter is now sent to the execution flow as a Throwable rather than an Exception. --- .../controller/callbacks/ChannelChoiceCallback.java | 4 ++-- .../voting/controller/callbacks/VotingCallback.java | 2 +- .../src/main/java/meerkat/voting/ui/SystemConsoleUI.java | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/voting-booth/src/main/java/meerkat/voting/controller/callbacks/ChannelChoiceCallback.java b/voting-booth/src/main/java/meerkat/voting/controller/callbacks/ChannelChoiceCallback.java index a87fe0a..7b97a82 100644 --- a/voting-booth/src/main/java/meerkat/voting/controller/callbacks/ChannelChoiceCallback.java +++ b/voting-booth/src/main/java/meerkat/voting/controller/callbacks/ChannelChoiceCallback.java @@ -35,8 +35,8 @@ public class ChannelChoiceCallback extends ControllerCallback @Override public void onFailure(Throwable t) { - if (t instanceof VoterCancelException) { - // voter has cancelled during the UI channel choice process. A VoterCancelException is thrown + if (t instanceof VoterCancelThrowable) { + // voter has cancelled during the UI channel choice process. A VoterCancelThrowable is thrown logger.debug("ChannelChoiceCallback got a cancellation response"); enqueueCommand(new RestartVotingCommand(getRequestIdentifier(), getBallotSerialNumber())); } diff --git a/voting-booth/src/main/java/meerkat/voting/controller/callbacks/VotingCallback.java b/voting-booth/src/main/java/meerkat/voting/controller/callbacks/VotingCallback.java index b389884..96c940b 100644 --- a/voting-booth/src/main/java/meerkat/voting/controller/callbacks/VotingCallback.java +++ b/voting-booth/src/main/java/meerkat/voting/controller/callbacks/VotingCallback.java @@ -34,7 +34,7 @@ public class VotingCallback extends ControllerCallback> { @Override public void onFailure(Throwable t) { - if (t instanceof VoterCancelException) { + if (t instanceof VoterCancelThrowable) { logger.debug("VotingCallback got a cancellation response"); enqueueCommand(new RestartVotingCommand(getRequestIdentifier(), getBallotSerialNumber())); } diff --git a/voting-booth/src/main/java/meerkat/voting/ui/SystemConsoleUI.java b/voting-booth/src/main/java/meerkat/voting/ui/SystemConsoleUI.java index bc3ac92..b8a3828 100644 --- a/voting-booth/src/main/java/meerkat/voting/ui/SystemConsoleUI.java +++ b/voting-booth/src/main/java/meerkat/voting/ui/SystemConsoleUI.java @@ -155,7 +155,7 @@ public class SystemConsoleUI implements VotingBoothUI, Runnable { List answers = askVoterForAnswers(command.getQuestions()); command.getCallback().onSuccess(answers); } - catch (VoterCancelException e) { + catch (VoterCancelThrowable e) { command.getCallback().onFailure(e); } catch (IOException e) { @@ -179,7 +179,7 @@ public class SystemConsoleUI implements VotingBoothUI, Runnable { List answers = askVoterForAnswers(command.getQuestions()); command.getCallback().onSuccess(answers); } - catch (VoterCancelException e) { + catch (VoterCancelThrowable e) { command.getCallback().onFailure(e); } catch (IOException e) { @@ -339,7 +339,7 @@ public class SystemConsoleUI implements VotingBoothUI, Runnable { } } - private List askVoterForAnswers(List questions) throws VoterCancelException, IOException { + private List askVoterForAnswers(List questions) throws VoterCancelThrowable, IOException { assertQuestionsAreValid (questions); @@ -354,7 +354,7 @@ public class SystemConsoleUI implements VotingBoothUI, Runnable { String s = readInputLine(); if ((s.equals("cancel") || s.equals("c")) || (index == 0 && (s.equals("back") || s.equals("b")))) { - throw new VoterCancelException(); + throw new VoterCancelThrowable(); } else if (s.equals("back") || s.equals("b")) { --index;