A cancel by the voter is now sent to the execution flow as a Throwable
rather than an Exception.vbdev2
							parent
							
								
									438df78e36
								
							
						
					
					
						commit
						3a5908ac49
					
				| 
						 | 
				
			
			@ -35,8 +35,8 @@ public class ChannelChoiceCallback extends ControllerCallback<List<BallotAnswer>
 | 
			
		|||
 | 
			
		||||
    @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()));
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,7 +34,7 @@ public class VotingCallback extends ControllerCallback<List<BallotAnswer>> {
 | 
			
		|||
 | 
			
		||||
    @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()));
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -155,7 +155,7 @@ public class SystemConsoleUI implements VotingBoothUI, Runnable {
 | 
			
		|||
            List<BallotAnswer> 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<BallotAnswer> 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<BallotAnswer> askVoterForAnswers(List<BallotQuestion> questions) throws VoterCancelException, IOException {
 | 
			
		||||
    private List<BallotAnswer> askVoterForAnswers(List<BallotQuestion> 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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue