Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
replace InfoResult with OperationSoftFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-medeiros committed Feb 15, 2016
1 parent 8e3b60a commit f6c38a9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 46 deletions.
33 changes: 0 additions & 33 deletions plugin_tooling/src-lang/melnorme/lang/tooling/data/InfoResult.java

This file was deleted.

Expand Up @@ -13,7 +13,6 @@

import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull;

import melnorme.lang.tooling.data.InfoResult;
import melnorme.utilbox.concurrency.ICancelMonitor;
import melnorme.utilbox.concurrency.OperationCancellation;
import melnorme.utilbox.core.CommonException;
Expand All @@ -33,7 +32,7 @@ public AbstractSingleToolOperation(IOperationService opHelper, String toolPath,
this.nonZeroExitIsFatal = nonZeroResultIsFatal;
}

public RESULT execute(ICancelMonitor cm) throws CommonException, OperationCancellation, InfoResult {
public RESULT execute(ICancelMonitor cm) throws CommonException, OperationCancellation, OperationSoftFailure {
ProcessBuilder pb = createProcessBuilder();
ExternalProcessResult result = opHelper.runProcess(pb, toolInput, cm);
return handleProcessResult(result);
Expand All @@ -42,12 +41,12 @@ public RESULT execute(ICancelMonitor cm) throws CommonException, OperationCancel
protected abstract ProcessBuilder createProcessBuilder() throws CommonException;

@Override
protected void handleNonZeroExitCode(ExternalProcessResult result) throws CommonException, InfoResult {
protected void handleNonZeroExitCode(ExternalProcessResult result) throws CommonException, OperationSoftFailure {
String nonZeroExitMsg = getToolName() + " did not complete successfully.";
if(nonZeroExitIsFatal) {
throw new CommonException(nonZeroExitMsg);
} else {
throw new InfoResult(nonZeroExitMsg);
throw new OperationSoftFailure(nonZeroExitMsg);
}
}

Expand Down
Expand Up @@ -10,7 +10,6 @@
*******************************************************************************/
package melnorme.lang.tooling.ops;

import melnorme.lang.tooling.data.InfoResult;
import melnorme.utilbox.concurrency.OperationCancellation;
import melnorme.utilbox.core.CommonException;
import melnorme.utilbox.misc.StringUtil;
Expand All @@ -23,7 +22,7 @@ public AbstractToolOperation2() {
}

public RESULT handleProcessResult(ExternalProcessResult result)
throws CommonException, OperationCancellation, InfoResult {
throws CommonException, OperationCancellation, OperationSoftFailure {
if(result.exitValue != 0) {
handleNonZeroExitCode(result);
}
Expand All @@ -32,14 +31,14 @@ public RESULT handleProcessResult(ExternalProcessResult result)
}

protected abstract void handleNonZeroExitCode(ExternalProcessResult result)
throws CommonException, OperationCancellation, InfoResult;
throws CommonException, OperationCancellation, OperationSoftFailure;

protected RESULT doHandleProcessResult(ExternalProcessResult result)
throws CommonException, OperationCancellation, InfoResult {
throws CommonException, OperationCancellation, OperationSoftFailure {
return handleProcessOutput(result.getStdOutBytes().toString(StringUtil.UTF8));
}

protected abstract RESULT handleProcessOutput(String output)
throws CommonException, OperationCancellation, InfoResult;
throws CommonException, OperationCancellation, OperationSoftFailure;

}
Expand Up @@ -12,7 +12,6 @@


import melnorme.lang.tooling.ToolingMessages;
import melnorme.lang.tooling.data.InfoResult;
import melnorme.lang.utils.parse.StringParseSource;
import melnorme.utilbox.concurrency.OperationCancellation;
import melnorme.utilbox.core.CommonException;
Expand All @@ -27,7 +26,7 @@ public AbstractToolOutputParser() {
public RESULT parse(ExternalProcessResult result) throws CommonException, OperationCancellation {
try {
return handleProcessResult(result);
} catch(InfoResult e) {
} catch(OperationSoftFailure e) {
throw e.toCommonException();
}
}
Expand Down
Expand Up @@ -15,7 +15,6 @@
import java.nio.file.Path;
import java.util.ArrayList;

import melnorme.lang.tooling.data.InfoResult;
import melnorme.lang.tooling.data.Severity;
import melnorme.lang.tooling.data.StatusLevel;
import melnorme.lang.utils.parse.StringParseSource;
Expand All @@ -41,7 +40,7 @@ public final ArrayList<ToolSourceMessage> parseOutput(ExternalProcessResult buil
throws CommonException, OperationCancellation {
try {
return handleProcessResult(buildResult);
} catch(InfoResult e) {
} catch(OperationSoftFailure e) {
throw e.toCommonException();
}
}
Expand Down
Expand Up @@ -12,6 +12,8 @@

import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull;

import melnorme.utilbox.core.CommonException;

/**
* Helper throwable result for "soft" failures: these are non-critical failures,
* such as invoking content assist on a source location where that operation cannot be performed.
Expand All @@ -25,4 +27,13 @@ public OperationSoftFailure(String message) {
super(assertNotNull(message));
}

@Override
public String getMessage() {
return super.getMessage();
}

public CommonException toCommonException() {
return new CommonException(getMessage());
}

}

0 comments on commit f6c38a9

Please sign in to comment.