git4idea: Ensuring that either exception is thrown or non-null stdout is returned from GitSimpleHandler.run()

This commit is contained in:
Constantine Plotnikov
2010-03-31 20:17:57 +04:00
parent 1363fe0f86
commit 4e8578dce0
2 changed files with 19 additions and 12 deletions
@@ -192,18 +192,23 @@ public class GitSimpleHandler extends GitHandler {
final String[] result = new String[1];
addListener(new GitHandlerListener() {
public void processTerminated(final int exitCode) {
if (exitCode == 0 || isIgnoredErrorCode(exitCode)) {
result[0] = getStdout();
try {
if (exitCode == 0 || isIgnoredErrorCode(exitCode)) {
result[0] = getStdout();
}
else {
String msg = getStderr();
if (msg.length() == 0) {
msg = getStdout();
}
if (msg.length() == 0) {
msg = GitBundle.message("git.error.exit", exitCode);
}
ex[0] = new VcsException(msg);
}
}
else {
String msg = getStderr();
if (msg.length() == 0) {
msg = getStdout();
}
if (msg.length() == 0) {
msg = GitBundle.message("git.error.exit", exitCode);
}
ex[0] = new VcsException(msg);
catch (Exception t) {
ex[0] = new VcsException(t.toString(), t);
}
}
@@ -15,6 +15,8 @@
*/
package git4idea.commands;
import org.jetbrains.annotations.NotNull;
/**
* A parser of strings that is oriented to scanning typical git outputs
*/
@@ -33,7 +35,7 @@ public class StringScanner {
*
* @param text the text to scan
*/
public StringScanner(final String text) {
public StringScanner(@NotNull final String text) {
myText = text;
myPosition = 0;
}