diff options
| author | Mathias Kinzler | 2010-04-06 16:04:49 +0000 |
|---|---|---|
| committer | Robin Rosenberg | 2010-04-14 19:25:09 +0000 |
| commit | af6b4e2fb50a8b04318b1547d5cb7a2284a04835 (patch) | |
| tree | 4a76d0cf3e9359aaf2762403bda6820cfbe2d815 | |
| parent | c1dd74cd0a0ad89514641aea81bb9a3bfbbdb50c (diff) | |
| download | egit-af6b4e2fb50a8b04318b1547d5cb7a2284a04835.tar.gz egit-af6b4e2fb50a8b04318b1547d5cb7a2284a04835.tar.xz egit-af6b4e2fb50a8b04318b1547d5cb7a2284a04835.zip | |
Avoid Exception construction in utility method
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>
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 a63dcfc381..cf78246e74 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 6c78fc023d..cfab6b926b 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 d7b422e351..904e4a9fb4 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 d8ce1c887e..01a9c0413b 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 d46a143910..d9d104cb20 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 32a8c86dde..c763cfc406 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 f076471272..aa305b9678 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 d06b33d23c..da6ec02d92 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 f694b4dcf8..66d822763c 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 40bed0acae..f3b0ad0e11 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 0e037226aa..da646853e7 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 9491ab0865..2d0307f0a8 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); } |
