summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMathias Kinzler2010-04-06 12:04:49 (EDT)
committer Robin Rosenberg2010-04-14 15:25:09 (EDT)
commitaf6b4e2fb50a8b04318b1547d5cb7a2284a04835 (patch)
tree4a76d0cf3e9359aaf2762403bda6820cfbe2d815
parentc1dd74cd0a0ad89514641aea81bb9a3bfbbdb50c (diff)
downloadegit-af6b4e2fb50a8b04318b1547d5cb7a2284a04835.zip
egit-af6b4e2fb50a8b04318b1547d5cb7a2284a04835.tar.gz
egit-af6b4e2fb50a8b04318b1547d5cb7a2284a04835.tar.bz2
Avoid Exception construction in utility methodrefs/changes/03/503/3
Exceptions should not be constructed in utility methods since this will result in wrong strack trace information. Change-Id: I92d1c5d86e41374829e436580cfc6b74b1d2eec1 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java11
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/UpdateJob.java10
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java4
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java6
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/TrackOperation.java6
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java6
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java1
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java1
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java1
12 files changed, 35 insertions, 34 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
index a63dcfc..cf78246 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
@@ -9,7 +9,6 @@
*******************************************************************************/
package org.eclipse.egit.core;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
@@ -41,16 +40,14 @@ public class Activator extends Plugin {
}
/**
- * Utility method to help throwing errors in the Egit plugin. This method
- * does not actually throw the exception, but just creates an instance.
+ * Utility to create an error status for this plug-in.
*
* @param message User comprehensible message
* @param thr cause
- * @return an Initialized {@link CoreException}
+ * @return an initialized error status
*/
- public static CoreException error(final String message, final Throwable thr) {
- return new CoreException(new Status(IStatus.ERROR, getPluginId(), 0,
- message, thr));
+ public static IStatus error(final String message, final Throwable thr) {
+ return new Status(IStatus.ERROR, getPluginId(), 0, message, thr);
}
/**
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/UpdateJob.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/UpdateJob.java
index 6c78fc0..cfab6b9 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/UpdateJob.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/UpdateJob.java
@@ -114,7 +114,7 @@ public class UpdateJob extends Job {
} catch (IOException e) {
if (GitTraceLocation.CORE.isActive())
GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
- throw Activator.error(CoreText.UpdateOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.UpdateOperation_failed, e));
}
return true;
}
@@ -135,19 +135,19 @@ public class UpdateJob extends Job {
rm.getRepository().getIndex().write();
}
} catch (NotSupportedException e) {
- return Activator.error(e.getMessage(),e).getStatus();
+ return Activator.error(e.getMessage(),e);
} catch (RuntimeException e) {
if (GitTraceLocation.CORE.isActive())
GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
- return Activator.error(CoreText.UpdateOperation_failed, e).getStatus();
+ return Activator.error(CoreText.UpdateOperation_failed, e);
} catch (IOException e) {
if (GitTraceLocation.CORE.isActive())
GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
- return Activator.error(CoreText.UpdateOperation_failed, e).getStatus();
+ return Activator.error(CoreText.UpdateOperation_failed, e);
} catch (CoreException e) {
if (GitTraceLocation.CORE.isActive())
GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
- return Activator.error(CoreText.UpdateOperation_failed, e).getStatus();
+ return Activator.error(CoreText.UpdateOperation_failed, e);
} finally {
try {
final Iterator i = tomerge.keySet().iterator();
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
index d7b422e..904e4a9 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
@@ -81,9 +81,9 @@ public class AddToIndexOperation implements IWorkspaceRunnable {
}
} catch (RuntimeException e) {
- throw Activator.error(CoreText.AddToIndexOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.AddToIndexOperation_failed, e));
} catch (IOException e) {
- throw Activator.error(CoreText.AddToIndexOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.AddToIndexOperation_failed, e));
} finally {
for (final RepositoryMapping rm : mappings.keySet())
rm.fireRepositoryChanged();
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java
index d8ce1c8..01a9c04 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java
@@ -82,9 +82,9 @@ public class AssumeUnchangedOperation implements IWorkspaceRunnable {
editor.commit();
}
} catch (RuntimeException e) {
- throw Activator.error(CoreText.UntrackOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, e));
} catch (IOException e) {
- throw Activator.error(CoreText.UntrackOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, e));
} finally {
for (final RepositoryMapping rm : mappings.keySet())
rm.fireRepositoryChanged();
@@ -109,7 +109,7 @@ public class AssumeUnchangedOperation implements IWorkspaceRunnable {
try {
cache = DirCache.lock(db);
} catch (IOException err) {
- throw Activator.error(CoreText.UntrackOperation_failed, err);
+ throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, err));
}
caches.put(db, cache);
mappings.put(rm, rm);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/TrackOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/TrackOperation.java
index d46a143..d9d104c 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/TrackOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/TrackOperation.java
@@ -118,7 +118,7 @@ public class TrackOperation implements IWorkspaceRunnable {
} catch (IOException e) {
if (GitTraceLocation.CORE.isActive())
GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
- throw Activator.error(CoreText.AddOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.AddOperation_failed, e));
}
return true;
}
@@ -138,11 +138,11 @@ public class TrackOperation implements IWorkspaceRunnable {
} catch (RuntimeException e) {
if (GitTraceLocation.CORE.isActive())
GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
- throw Activator.error(CoreText.AddOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.AddOperation_failed, e));
} catch (IOException e) {
if (GitTraceLocation.CORE.isActive())
GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
- throw Activator.error(CoreText.AddOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.AddOperation_failed, e));
} finally {
try {
final Iterator i = tomerge.keySet().iterator();
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java
index 32a8c86..c763cfc 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java
@@ -87,9 +87,9 @@ public class UntrackOperation implements IWorkspaceRunnable {
editor.commit();
}
} catch (RuntimeException e) {
- throw Activator.error(CoreText.UntrackOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, e));
} catch (IOException e) {
- throw Activator.error(CoreText.UntrackOperation_failed, e);
+ throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, e));
} finally {
for (final RepositoryMapping rm : mappings.keySet())
rm.fireRepositoryChanged();
@@ -114,7 +114,7 @@ public class UntrackOperation implements IWorkspaceRunnable {
try {
e = DirCache.lock(db).editor();
} catch (IOException err) {
- throw Activator.error(CoreText.UntrackOperation_failed, err);
+ throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, err));
}
edits.put(db, e);
mappings.put(rm, rm);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
index f076471..aa305b9 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
@@ -305,7 +305,7 @@ public class GitProjectData {
dotGit.setTeamPrivateMember(true);
}
} catch (IOException err) {
- throw Activator.error(CoreText.Error_CanonicalFile, err);
+ throw new CoreException(Activator.error(CoreText.Error_CanonicalFile, err));
}
}
}
@@ -389,15 +389,15 @@ public class GitProjectData {
}
}
} catch (IOException ioe) {
- throw Activator.error(NLS.bind(CoreText.GitProjectData_saveFailed,
- dat), ioe);
+ throw new CoreException(Activator.error(NLS.bind(CoreText.GitProjectData_saveFailed,
+ dat), ioe));
}
dat.delete();
if (!tmp.renameTo(dat)) {
tmp.delete();
- throw Activator.error(NLS.bind(CoreText.GitProjectData_saveFailed,
- dat), null);
+ throw new CoreException(Activator.error(NLS.bind(CoreText.GitProjectData_saveFailed,
+ dat), null));
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
index d06b33d..da6ec02 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
@@ -99,17 +99,16 @@ public class Activator extends AbstractUIPlugin {
}
/**
- * Instantiate an error exception.
+ * Instantiate an error status.
*
* @param message
* description of the error
* @param thr
* cause of the error or null
- * @return an initialized {@link CoreException}
+ * @return an initialized error status
*/
- public static CoreException error(final String message, final Throwable thr) {
- return new CoreException(new Status(IStatus.ERROR, getPluginId(), 0,
- message, thr));
+ public static IStatus error(final String message, final Throwable thr) {
+ return new Status(IStatus.ERROR, getPluginId(), 0, message, thr);
}
/**
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java
index f694b4d..66d8227 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java
@@ -77,6 +77,7 @@ public class GitQuickDiffProvider implements IQuickDiffReferenceProvider {
try {
document = GitDocument.create(resource);
} catch (IOException e) {
+ // TODO throw an exception or log this?
Activator.error(UIText.QuickDiff_failedLoading, e);
}
return document;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java
index 40bed0a..f3b0ad0 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java
@@ -290,7 +290,9 @@ class CommitMessageViewer extends TextViewer implements ISelectionChangedListene
outputDiff(d, diff);
}
} catch (IOException e) {
- Activator.error(NLS.bind(UIText.CommitMessageViewer_errorGettingFileDifference,
+ // TODO throw an exception or log this?
+ Activator.error(NLS.bind(
+ UIText.CommitMessageViewer_errorGettingFileDifference,
commit.getId()), e);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java
index 0e03722..da64685 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java
@@ -37,6 +37,7 @@ class FileDiffContentProvider implements IStructuredContentProvider {
try {
diff = FileDiff.compute(walk, commit);
} catch (IOException err) {
+ // TODO throw an exception or log this?
Activator.error(NLS.bind(UIText.FileDiffContentProvider_errorGettingDifference,
commit.getId()), err);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index 9491ab0..2d0307f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -401,6 +401,7 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
right = new EditableRevision(nextFile);
}
} catch (IOException e) {
+ // TODO throw an exception or log this?
Activator.error(NLS.bind(UIText.GitHistoryPage_errorLookingUpPath,
gitPath, commit.getId()), e);
}