Skip to content
This repository was archived by the owner on Apr 2, 2019. It is now read-only.

Commit 25b1ec6

Browse files
committed
SONARGITUB-19 Improve error reporting
1 parent 41e2608 commit 25b1ec6

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/main/java/org/sonar/plugins/github/GitHubPluginConfiguration.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.sonar.api.config.Settings;
2929
import org.sonar.api.utils.MessageException;
3030

31+
import static org.apache.commons.lang.StringUtils.isNotBlank;
32+
3133
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
3234
public class GitHubPluginConfiguration implements BatchComponent {
3335

@@ -51,7 +53,7 @@ public String repository() {
5153
if (settings.hasKey(GitHubPlugin.GITHUB_REPO)) {
5254
return repoFromProp();
5355
}
54-
if (settings.hasKey(CoreProperties.LINKS_SOURCES_DEV) || settings.hasKey(CoreProperties.LINKS_SOURCES)) {
56+
if (isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES_DEV)) || isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES))) {
5557
return repoFromScmProps();
5658
}
5759
throw MessageException.of("Unable to determine GitHub repository name for this project. Please provide it using property '" + GitHubPlugin.GITHUB_REPO
@@ -60,11 +62,11 @@ public String repository() {
6062

6163
private String repoFromScmProps() {
6264
String repo = null;
63-
if (settings.hasKey(CoreProperties.LINKS_SOURCES_DEV)) {
65+
if (isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES_DEV))) {
6466
String url = settings.getString(CoreProperties.LINKS_SOURCES_DEV);
6567
repo = extractRepoFromGitUrl(url);
6668
}
67-
if (repo == null && settings.hasKey(CoreProperties.LINKS_SOURCES)) {
69+
if (repo == null && isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES))) {
6870
String url = settings.getString(CoreProperties.LINKS_SOURCES);
6971
repo = extractRepoFromGitUrl(url);
7072
}

src/main/java/org/sonar/plugins/github/PullRequestFacade.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.sonar.api.batch.fs.InputFile;
4848
import org.sonar.api.batch.fs.InputPath;
4949
import org.sonar.api.scan.filesystem.PathResolver;
50+
import org.sonar.api.utils.MessageException;
5051

5152
/**
5253
* Facade for all WS interaction with GitHub.
@@ -83,7 +84,8 @@ public void init(int pullRequestNumber, File projectBaseDir) {
8384
loadExistingReviewComments();
8485
patchPositionMappingByFile = mapPatchPositionsToLines(pr);
8586
} catch (IOException e) {
86-
throw new IllegalStateException("Unable to perform GitHub WS operation", e);
87+
LOG.debug("Unable to perform GitHub WS operation", e);
88+
throw MessageException.of("Unable to perform GitHub WS operation: " + e.getMessage());
8789
}
8890
}
8991

0 commit comments

Comments
 (0)