Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Aniszczyk2011-05-31 13:00:42 +0000
committerCode Review2011-05-31 13:00:42 +0000
commit09b453dfaf2dc9dab9d9c4c7342f9ca0dba39b29 (patch)
treeb58cc558134719a9bd9ac8fd1e50746524cb125f /org.eclipse.mylyn.github.core
parentca2629fc130a6ad6f2ca806d09e95293e10a7aee (diff)
parentd3bab40e0781bb782c66404d434abd28685cdad6 (diff)
downloadegit-github-09b453dfaf2dc9dab9d9c4c7342f9ca0dba39b29.tar.gz
egit-github-09b453dfaf2dc9dab9d9c4c7342f9ca0dba39b29.tar.xz
egit-github-09b453dfaf2dc9dab9d9c4c7342f9ca0dba39b29.zip
Merge "Use wrapped exception when validating repo settings." into stable-1.0
Diffstat (limited to 'org.eclipse.mylyn.github.core')
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHub.java13
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHubException.java13
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java4
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java4
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java4
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/issue/IssueConnector.java12
6 files changed, 36 insertions, 14 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHub.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHub.java
index 6206ad0f..064e7629 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHub.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHub.java
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.mylyn.internal.github.core;
+import java.io.IOException;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.ILog;
@@ -19,6 +20,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.client.RequestException;
/**
* GitHub class
@@ -98,6 +100,17 @@ public class GitHub {
}
/**
+ * Create error status from {@link IOException} that wraps it in a
+ * {@link GitHubException} if it is a {@link RequestException}
+ *
+ * @param e
+ * @return status
+ */
+ public static IStatus createWrappedStatus(IOException e) {
+ return createErrorStatus(GitHubException.wrap(e));
+ }
+
+ /**
* Get log
*
* @return log
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHubException.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHubException.java
index a0a58cf7..4048b65d 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHubException.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/GitHubException.java
@@ -29,6 +29,19 @@ public class GitHubException extends IOException {
private static final long serialVersionUID = -1456910662911777231L;
/**
+ * Wraps the given {@link IOException} with a {@link GitHubException} if it
+ * is a {@link RequestException} instance.
+ *
+ * @param exception
+ * @return wrapped exception
+ */
+ public static IOException wrap(IOException exception) {
+ return exception instanceof RequestException ? new GitHubException(
+ (RequestException) exception) : exception;
+
+ }
+
+ /**
* Create GitHub exception from {@link RequestException}
*
* @param cause
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java
index 833f349a..d35abe9f 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java
@@ -69,7 +69,7 @@ public class GistAttachmentHandler extends AbstractTaskAttachmentHandler {
throw new IOException("Unable to obtain raw file URL from Gist"); //$NON-NLS-1$
return new URL(urlAttribute.getValue()).openStream();
} catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
+ throw new CoreException(GitHub.createWrappedStatus(e));
}
}
@@ -111,7 +111,7 @@ public class GistAttachmentHandler extends AbstractTaskAttachmentHandler {
file.setContent(output.toString());
service.updateGist(gist);
} catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
+ throw new CoreException(GitHub.createWrappedStatus(e));
} finally {
try {
input.close();
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java
index 11f08457..24f6f888 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java
@@ -138,7 +138,7 @@ public class GistConnector extends AbstractRepositoryConnector {
return data;
} catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
+ throw new CoreException(GitHub.createWrappedStatus(e));
}
}
@@ -206,7 +206,7 @@ public class GistConnector extends AbstractRepositoryConnector {
collector.accept(data);
}
} catch (IOException e) {
- status = GitHub.createErrorStatus(e);
+ status = GitHub.createWrappedStatus(e);
}
return status;
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java
index e68a2900..3e22ecb2 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java
@@ -231,7 +231,7 @@ public class GistTaskDataHandler extends AbstractTaskDataHandler {
try {
gist = service.createGist(gist);
} catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
+ throw new CoreException(GitHub.createWrappedStatus(e));
}
response = new RepositoryResponse(ResponseKind.TASK_CREATED,
gist.getId());
@@ -244,7 +244,7 @@ public class GistTaskDataHandler extends AbstractTaskDataHandler {
service.updateGist(gist);
} catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
+ throw new CoreException(GitHub.createWrappedStatus(e));
}
response = new RepositoryResponse(ResponseKind.TASK_UPDATED,
taskData.getTaskId());
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/issue/IssueConnector.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/issue/IssueConnector.java
index d74fce97..3f978788 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/issue/IssueConnector.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/issue/IssueConnector.java
@@ -33,7 +33,6 @@ import org.eclipse.egit.github.core.Label;
import org.eclipse.egit.github.core.Milestone;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.client.GitHubClient;
-import org.eclipse.egit.github.core.client.RequestException;
import org.eclipse.egit.github.core.service.IssueService;
import org.eclipse.egit.github.core.service.LabelService;
import org.eclipse.egit.github.core.service.MilestoneService;
@@ -43,7 +42,6 @@ import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.commons.net.Policy;
import org.eclipse.mylyn.internal.github.core.GitHub;
-import org.eclipse.mylyn.internal.github.core.GitHubException;
import org.eclipse.mylyn.internal.github.core.QueryUtils;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
@@ -120,7 +118,7 @@ public class IssueConnector extends AbstractRepositoryConnector {
this.repositoryLabels.put(repository, labels);
return labels;
} catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
+ throw new CoreException(GitHub.createWrappedStatus(e));
}
}
@@ -173,7 +171,7 @@ public class IssueConnector extends AbstractRepositoryConnector {
this.repositoryMilestones.put(repository, milestones);
return milestones;
} catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
+ throw new CoreException(GitHub.createWrappedStatus(e));
}
}
@@ -307,10 +305,8 @@ public class IssueConnector extends AbstractRepositoryConnector {
}
monitor.worked(1);
}
- } catch (RequestException e) {
- result = GitHub.createErrorStatus(new GitHubException(e));
} catch (IOException e) {
- result = GitHub.createErrorStatus(e);
+ result = GitHub.createWrappedStatus(e);
}
monitor.done();
@@ -335,7 +331,7 @@ public class IssueConnector extends AbstractRepositoryConnector {
return taskDataHandler.createTaskData(repository, monitor,
repo.getOwner(), repo.getName(), issue, comments);
} catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
+ throw new CoreException(GitHub.createWrappedStatus(e));
}
}

Back to the top