aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2010-04-28 05:33:10 (EDT)
committerRobin Rosenberg2010-05-02 05:58:44 (EDT)
commit373162511e9b12060fef0092359835f407441a90 (patch)
tree089cc645c59808a0d5a4e7c6517254f243289abc
parente494ea152d0f0663d3004ab5638ff85ac2654671 (diff)
downloadegit-373162511e9b12060fef0092359835f407441a90.zip
egit-373162511e9b12060fef0092359835f407441a90.tar.gz
egit-373162511e9b12060fef0092359835f407441a90.tar.bz2
Improve error handling in EGit UIrefs/changes/23/623/3
Use recently introduced error handling method Activator.handleError instead of using ErrorDialog. Change-Id: I97d918c572a141feea1b39c13ff7dcff2d8cc5ca Signed-off-by: Jens Baumgart <jens.baumgart@sap.com> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java12
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionDialog.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySource.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryRemotePropertySource.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties8
11 files changed, 51 insertions, 70 deletions
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 aeaa46c..613edc0 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
@@ -102,6 +102,19 @@ public class Activator extends AbstractUIPlugin {
}
/**
+ * Shows an error. The error is NOT logged.
+ *
+ * @param message
+ * a localized message
+ * @param throwable
+ */
+ public static void showError(String message, Throwable throwable) {
+ IStatus status = new Status(IStatus.ERROR, getPluginId(), message,
+ throwable);
+ StatusManager.getManager().handle(status, StatusManager.SHOW);
+ }
+
+ /**
* Get the theme used by this plugin.
*
* @return our theme.
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index bef427f..e3567fe 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -229,9 +229,6 @@ public class UIText extends NLS {
public static String GitHistoryPage_openFailed;
/** */
- public static String GitHistoryPage_seeLog;
-
- /** */
public static String GitProjectPropertyPage_LabelBranch;
/** */
@@ -1303,15 +1300,6 @@ public class UIText extends NLS {
public static String BranchSelectionDialog_ErrorCouldNotRenameRef;
/** */
- public static String BranchSelectionDialog_ErrorCouldNotRenameRef2;
-
- /** */
- public static String BranchSelectionDialog_BranchSelectionDialog_CreateFailedTitle;
-
- /** */
- public static String BranchSelectionDialog_BranchSelectionDialog_RenamedFailedTitle;
-
- /** */
public static String BranchSelectionDialog_BranchSuffix_Current;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java
index 88ec481..a01f1ed 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java
@@ -201,9 +201,8 @@ public class GitCloneWizard extends Wizard implements IImportWizard {
UIText.GitCloneWizard_CloneCanceledMessage);
return false;
} catch (Exception e) {
- Activator.logError(UIText.GitCloneWizard_CloneFailedHeading, e);
- MessageDialog.openError(getShell(),
- UIText.GitCloneWizard_CloneFailedHeading, e.toString());
+ Activator.handleError(UIText.GitCloneWizard_CloneFailedHeading,
+ e, true);
return false;
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionDialog.java
index 686e9d9..7ac02ca 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/BranchSelectionDialog.java
@@ -381,7 +381,6 @@ public class BranchSelectionDialog extends Dialog {
if (renameRef.rename() != Result.RENAMED) {
reportError(
null,
- UIText.BranchSelectionDialog_BranchSelectionDialog_RenamedFailedTitle,
UIText.BranchSelectionDialog_ErrorCouldNotRenameRef,
refName, newRefName, renameRef
.getResult());
@@ -389,7 +388,6 @@ public class BranchSelectionDialog extends Dialog {
} catch (Throwable e1) {
reportError(
e1,
- UIText.BranchSelectionDialog_BranchSelectionDialog_RenamedFailedTitle,
UIText.BranchSelectionDialog_ErrorCouldNotRenameRef,
refName, newRefName, e1.getMessage());
}
@@ -399,7 +397,6 @@ public class BranchSelectionDialog extends Dialog {
} catch (Throwable e1) {
reportError(
e1,
- UIText.BranchSelectionDialog_BranchSelectionDialog_RenamedFailedTitle,
UIText.BranchSelectionDialog_ErrorCouldNotRefreshBranchList);
}
}
@@ -451,7 +448,6 @@ public class BranchSelectionDialog extends Dialog {
} catch (Throwable e1) {
reportError(
e1,
- UIText.BranchSelectionDialog_BranchSelectionDialog_CreateFailedTitle,
UIText.BranchSelectionDialog_ErrorCouldNotCreateNewRef,
newRefName);
}
@@ -460,7 +456,6 @@ public class BranchSelectionDialog extends Dialog {
fillTreeWithBranches(newRefName);
} catch (Throwable e1) {
reportError(e1,
- UIText.BranchSelectionDialog_BranchSelectionDialog_CreateFailedTitle,
UIText.BranchSelectionDialog_ErrorCouldNotRefreshBranchList);
}
}
@@ -481,10 +476,8 @@ public class BranchSelectionDialog extends Dialog {
return super.getShellStyle() | SWT.RESIZE;
}
- private void reportError(Throwable e, String title, String message,
- Object... args) {
+ private void reportError(Throwable e, String message, Object... args) {
String msg = NLS.bind(message, args);
- MessageDialog.openError(getShell(), title, msg);
- Activator.logError(msg, e);
+ Activator.handleError(msg, e, true);
}
}
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 ed87e59..78bc627 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
@@ -1323,9 +1323,7 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
}
}
if (errorOccured)
- MessageDialog.openError(getSite().getShell(),
- UIText.GitHistoryPage_openFailed,
- UIText.GitHistoryPage_seeLog);
+ Activator.showError(UIText.GitHistoryPage_openFailed, null);
if (ids.size() > 0) {
String idList = ""; //$NON-NLS-1$
for (ObjectId objectId : ids) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
index 6feee36..2882127 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
@@ -800,9 +800,9 @@ public class RepositoriesView extends ViewPart implements ISelectionProvider {
config.save();
scheduleRefresh();
} catch (IOException e1) {
- MessageDialog.openError(getSite().getShell(),
- UIText.RepositoriesView_ErrorHeader, e1
- .getMessage());
+ Activator.handleError(
+ UIText.RepositoriesView_ErrorHeader, e1,
+ true);
}
}
@@ -845,9 +845,9 @@ public class RepositoriesView extends ViewPart implements ISelectionProvider {
config.save();
scheduleRefresh();
} catch (IOException e1) {
- MessageDialog.openError(getSite().getShell(),
- UIText.RepositoriesView_ErrorHeader, e1
- .getMessage());
+ Activator.handleError(
+ UIText.RepositoriesView_ErrorHeader, e1,
+ true);
}
}
@@ -879,9 +879,9 @@ public class RepositoriesView extends ViewPart implements ISelectionProvider {
config.save();
scheduleRefresh();
} catch (IOException e1) {
- MessageDialog.openError(getSite().getShell(),
- UIText.RepositoriesView_ErrorHeader, e1
- .getMessage());
+ Activator.handleError(
+ UIText.RepositoriesView_ErrorHeader, e1,
+ true);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySource.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySource.java
index 93628cd..4545060 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySource.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySource.java
@@ -23,7 +23,6 @@ import org.eclipse.egit.ui.UIText;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Config;
@@ -92,13 +91,10 @@ public class RepositoryPropertySource implements IPropertySource,
userHomeConfig.load();
repositoryConfig.load();
} catch (IOException e) {
- // TODO refactor to a method and react on exceptions
- e.printStackTrace();
+ showExceptionMessage(e);
} catch (ConfigInvalidException e) {
- // TODO refactor to a method and react on exceptions
- e.printStackTrace();
+ showExceptionMessage(e);
}
-
}
private void makeActions() {
@@ -460,8 +456,7 @@ public class RepositoryPropertySource implements IPropertySource,
}
private void showExceptionMessage(Exception e) {
- MessageDialog.openError(myPage.getSite().getShell(),
- UIText.RepositoryPropertySource_ErrorHeader, e.getMessage());
+ org.eclipse.egit.ui.Activator.handleError(UIText.RepositoryPropertySource_ErrorHeader, e, true);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryRemotePropertySource.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryRemotePropertySource.java
index b35c083..c68dc6d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryRemotePropertySource.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryRemotePropertySource.java
@@ -14,8 +14,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.RepositoryConfig;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
@@ -32,8 +32,6 @@ public class RepositoryRemotePropertySource implements IPropertySource {
private final String myName;
- private final PropertySheetPage myPage;
-
/**
* @param config
* @param remoteName
@@ -44,7 +42,6 @@ public class RepositoryRemotePropertySource implements IPropertySource {
String remoteName, PropertySheetPage page) {
myConfig = config;
myName = remoteName;
- myPage = page;
}
public Object getEditableValue() {
@@ -56,9 +53,11 @@ public class RepositoryRemotePropertySource implements IPropertySource {
try {
myConfig.load();
} catch (IOException e) {
- showExceptionMessage(e);
+ Activator.handleError(
+ UIText.RepositoryRemotePropertySource_ErrorHeader, e, true);
} catch (ConfigInvalidException e) {
- showExceptionMessage(e);
+ Activator.handleError(
+ UIText.RepositoryRemotePropertySource_ErrorHeader, e, true);
}
List<IPropertyDescriptor> resultList = new ArrayList<IPropertyDescriptor>();
PropertyDescriptor desc = new PropertyDescriptor(RepositoriesView.URL,
@@ -105,9 +104,4 @@ public class RepositoryRemotePropertySource implements IPropertySource {
// read-only
}
- private void showExceptionMessage(Exception e) {
- MessageDialog.openError(myPage.getSite().getShell(),
- UIText.RepositoryRemotePropertySource_ErrorHeader, e
- .getMessage());
- }
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java
index 7334659..ae58105 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java
@@ -28,7 +28,6 @@ import org.eclipse.egit.core.Activator;
import org.eclipse.egit.ui.UIText;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -315,9 +314,9 @@ public class RepositorySearchDialog extends Dialog {
pd.run(true, true, action);
} catch (InvocationTargetException e1) {
- MessageDialog.openError(getShell(),
- UIText.RepositorySearchDialog_errorOccurred, e1
- .getCause().getMessage());
+ org.eclipse.egit.ui.Activator.handleError(
+ UIText.RepositorySearchDialog_errorOccurred,
+ e1, true);
} catch (InterruptedException e1) {
// ignore
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
index 62e8f73..92c4e41 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
@@ -24,16 +24,15 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.project.RepositoryFinder;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.UIIcons;
import org.eclipse.egit.ui.UIText;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -165,10 +164,17 @@ class ExistingOrNewPage extends WizardPage {
new NullProgressMonitor());
}
} catch (IOException e1) {
- MessageDialog.openError(getShell(), UIText.ExistingOrNewPage_ErrorFailedToCreateRepository, gitDir.toString() + ":\n" + e1.getMessage()); //$NON-NLS-1$
- Activator.logError("Failed to create repository at " + gitDir, e1); //$NON-NLS-1$
+ String msg = NLS
+ .bind(
+ UIText.ExistingOrNewPage_ErrorFailedToCreateRepository,
+ gitDir.toString());
+ org.eclipse.egit.ui.Activator.handleError(msg, e1, true);
} catch (CoreException e2) {
- Activator.logError(UIText.ExistingOrNewPage_ErrorFailedToRefreshRepository + gitDir, e2);
+ String msg = NLS
+ .bind(
+ UIText.ExistingOrNewPage_ErrorFailedToRefreshRepository,
+ gitDir);
+ org.eclipse.egit.ui.Activator.handleError(msg, e2, true);
}
for (TreeItem ti : tree.getSelection()) {
ti.setText(2, gitDir.toString());
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 8f8e515..d12a882 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -49,8 +49,8 @@ GenericOperationFailed={0} Failed
ExistingOrNewPage_CreateButton=&Create Repository
ExistingOrNewPage_title=Configure Git Repository
ExistingOrNewPage_description=Select Git Repository Location
-ExistingOrNewPage_ErrorFailedToCreateRepository=Failed to create repository
-ExistingOrNewPage_ErrorFailedToRefreshRepository=Failed to refresh project after creating repo at
+ExistingOrNewPage_ErrorFailedToCreateRepository=Failed to create repository {0}
+ExistingOrNewPage_ErrorFailedToRefreshRepository=Failed to refresh project after creating repo at {0}
ExistingOrNewPage_HeaderPath=Path
ExistingOrNewPage_HeaderProject=Project
ExistingOrNewPage_HeaderRepository=Repository
@@ -81,7 +81,6 @@ GitHistoryPage_find=Find
GitHistoryPage_notContainedInCommits=File {0} is not contained in the commits: {1}
GitHistoryPage_open=Open
GitHistoryPage_openFailed=Opening Editor failed
-GitHistoryPage_seeLog=See rrror log for details
GitProjectPropertyPage_LabelBranch=Branch:
GitProjectPropertyPage_LabelGitDir=Git directory:
GitProjectPropertyPage_LabelId=Id:
@@ -465,8 +464,6 @@ BranchAction_repositoryState=Repository state: {0}
BranchAction_unableToSwitchBranches=Unable to switch branches
BranchSelectionDialog_TitleCheckout=Checkout: {0}
BranchSelectionDialog_TitleReset=Reset: {0}
-BranchSelectionDialog_BranchSelectionDialog_CreateFailedTitle=New branch creation failed
-BranchSelectionDialog_BranchSelectionDialog_RenamedFailedTitle=Rename failed
BranchSelectionDialog_BranchSuffix_Current=\ (current)
BranchSelectionDialog_ErrorAlreadyExists=Already exists
BranchSelectionDialog_ErrorCouldNotCreateNewRef=Could not create new ref {0}
@@ -475,7 +472,6 @@ BranchSelectionDialog_ErrorCouldNotRefreshBranchList=Could not refresh list of b
BranchSelectionDialog_ErrorCouldNotResolve=Could not attempt to resolve {0}
BranchSelectionDialog_ErrorInvalidRefName=Invalid ref name
BranchSelectionDialog_ErrorCouldNotRenameRef=Failed to rename branch {0} -> {1}, status={2}
-BranchSelectionDialog_ErrorCouldNotRenameRef2=Failed to rename branch {0} -> {1}
BranchSelectionDialog_ErrorRenameFailed=Rename failed
BranchSelectionDialog_LocalBranches=Local Branches