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

Commit

Permalink
SONARGITUB-19 Improve error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju committed Apr 7, 2016
1 parent 41e2608 commit 25b1ec6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Expand Up @@ -28,6 +28,8 @@
import org.sonar.api.config.Settings;
import org.sonar.api.utils.MessageException;

import static org.apache.commons.lang.StringUtils.isNotBlank;

@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
public class GitHubPluginConfiguration implements BatchComponent {

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

private String repoFromScmProps() {
String repo = null;
if (settings.hasKey(CoreProperties.LINKS_SOURCES_DEV)) {
if (isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES_DEV))) {
String url = settings.getString(CoreProperties.LINKS_SOURCES_DEV);
repo = extractRepoFromGitUrl(url);
}
if (repo == null && settings.hasKey(CoreProperties.LINKS_SOURCES)) {
if (repo == null && isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES))) {
String url = settings.getString(CoreProperties.LINKS_SOURCES);
repo = extractRepoFromGitUrl(url);
}
Expand Down
Expand Up @@ -47,6 +47,7 @@
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.MessageException;

/**
* Facade for all WS interaction with GitHub.
Expand Down Expand Up @@ -83,7 +84,8 @@ public void init(int pullRequestNumber, File projectBaseDir) {
loadExistingReviewComments();
patchPositionMappingByFile = mapPatchPositionsToLines(pr);
} catch (IOException e) {
throw new IllegalStateException("Unable to perform GitHub WS operation", e);
LOG.debug("Unable to perform GitHub WS operation", e);
throw MessageException.of("Unable to perform GitHub WS operation: " + e.getMessage());
}
}

Expand Down

0 comments on commit 25b1ec6

Please sign in to comment.