Commit 305d708c authored by Pietro Braghieri's avatar Pietro Braghieri
Browse files

add failure value to ResultStatus enumerator

parent 1b3c0f56
......@@ -33,7 +33,8 @@ public class Request
{
unknown,
available,
failure
failure,
timeout
};
private final String key;
......
......@@ -602,8 +602,9 @@ public abstract class ToolRunner
*
* @param timeoutInMilliseconds the timeout in milliseconds
* @return the pair left is the exit value, the middle is the standard output as string, the right is the standard error as string
* @throws TimeoutException
*/
public synchronized Triple<Integer, String, String> get(long timeoutInMilliseconds)
public synchronized Triple<Integer, String, String> get(long timeoutInMilliseconds) throws TimeoutException
{
resultFile = null;
standardOutputFile = null;
......@@ -680,8 +681,10 @@ public abstract class ToolRunner
{
toolRunnerProcess.destroy();
}
return Triple.of(-1, "", "Execution timeout. Current timeout is " + timeoutInMilliseconds + " milliseconds");
logger.error("Execution timeout. Current timeout is " + timeoutInMilliseconds + " milliseconds");
throw to;
}
catch (Exception e)
{
......@@ -689,6 +692,7 @@ public abstract class ToolRunner
{
toolRunnerProcess.destroy();
}
logger.error(e.getMessage());
return Triple.of(-1, "", "Internal error: " + e.toString());
......
......@@ -97,10 +97,7 @@ public class ToolJob extends Job
{
if( runner == null )
{
request.setNotes("Internal error while executing the command");
logger.error(request.getNotes() + ". The runner is null");
jobFail();
jobFail("Unexpected condition: the runner is null");
return Status.CANCEL_STATUS;
}
......@@ -154,11 +151,10 @@ public class ToolJob extends Job
if( output == null )
{
request.setNotes("Unexpected fully empty result");
logger.error(request.getNotes() + ". The output is null");
jobFail();
final String errorMessage = "Unexpected fully empty result";
displayError(function.getName(), errorMessage);
jobFail(errorMessage);
return Status.CANCEL_STATUS;
}
......@@ -176,10 +172,10 @@ public class ToolJob extends Job
if( !runner.isSuccess(exitStatus) )
{
displayError(function.getName(), errorMessage);
runner.killToolRunnerProcess();
jobFail();
jobFail(errorMessage);
runner.killToolRunnerProcess();
return Status.CANCEL_STATUS;
}
......@@ -210,14 +206,11 @@ public class ToolJob extends Job
}
if( !resultProcessor.processResult() )
{
request.setNotes("Error processing the command result");
logger.error(request.getNotes());
{
jobFail("Error processing the command result");
runner.killToolRunnerProcess();
jobFail();
return Status.CANCEL_STATUS;
}
......@@ -232,26 +225,22 @@ public class ToolJob extends Job
}
catch( TimeoutException toe)
{
request.setNotes("Timeout expired");
logger.error(request.getNotes());
displayError(function.getName(), "Timeout expired. Try to increase the timeout in the preferences.");
final String errorMessage = "Timeout expired. Try increasing the timeout in the preferences.";
displayError(function.getName(), errorMessage);
jobTimeout(errorMessage);
runner.killToolRunnerProcess();
jobFail();
return Status.CANCEL_STATUS;
}
catch (Exception e)
{
request.setNotes("Internal error while executing the command");
logger.error(request.getNotes(), e.getMessage());
displayError(function.getName(), "Internal error while executing the command. For more info see the console");
final String errorMessage = "Internal error while executing the command";
displayError(function.getName(), errorMessage);
jobFail(errorMessage);
runner.killToolRunnerProcess();
jobFail();
return Status.CANCEL_STATUS;
}
finally
......@@ -308,9 +297,20 @@ public class ToolJob extends Job
requestEnd(ResultStatus.available);
}
protected void jobFail()
{
protected void jobFail(String errorMessage)
{
request.setNotes(errorMessage);
requestEnd(ResultStatus.failure);
logger.error(errorMessage);
}
protected void jobTimeout(String errorMessage)
{
request.setNotes(errorMessage);
requestEnd(ResultStatus.timeout);
logger.error(errorMessage);
}
protected void requestEnd(ResultStatus status)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment