Abort the installation wizard if a runtime exception happens

This commit is contained in:
snowleo 2011-10-26 19:46:40 +02:00
parent 48f8eb9788
commit 5641b1173c
2 changed files with 43 additions and 23 deletions

View File

@ -71,6 +71,8 @@ public abstract class AbstractState
abort();
return null;
}
try
{
final boolean found = reactOnAnswer(trimmedAnswer);
if (found)
{
@ -82,6 +84,12 @@ public abstract class AbstractState
return this;
}
}
catch (RuntimeException ex)
{
sender.sendMessage(ex.toString());
return this;
}
}
/**
* Do something based on the answer, that the user gave.

View File

@ -32,15 +32,19 @@ public class StateMachine extends WorkListener
}
public MachineResult askQuestion()
{
try
{
while (current.guessAnswer())
{
current = current.getNextState();
if (current == null)
{
result = MachineResult.DONE;
break;
}
}
if (current != null)
{
@ -50,6 +54,13 @@ public class StateMachine extends WorkListener
}
result = MachineResult.WAIT;
}
}
catch (RuntimeException ex)
{
player.sendMessage(ex.getMessage());
finish();
result = MachineResult.ABORT;
}
return result;
}
@ -135,6 +146,7 @@ public class StateMachine extends WorkListener
private void finish()
{
current = null;
iterator = null;
states.clear();
getPlugin().getServer().getPluginManager().callEvent(new InstallationFinishedEvent());