Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> --- .../src/org/spearce/egit/ui/UIText.java | 6 ++ .../ui/internal/dialogs/BranchSelectionDialog.java | 59 ++++++++++++-------- .../src/org/spearce/egit/ui/uitext.properties | 2 + 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java index aa31a93..c120327 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java @@ -899,6 +899,12 @@ 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.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/BranchSelectionDialog.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/BranchSelectionDialog.java index 28105af..43588ae 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/BranchSelectionDialog.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/BranchSelectionDialog.java @@ -104,7 +104,7 @@ getShell().setText( try { fillTreeWithBranches(null); - } catch (IOException e) { + } catch (Throwable e) { Activator.logError(UIText.BranchSelectionDialog_ErrorCouldNotRefresh, e); } @@ -294,6 +294,7 @@ public String isValid(String newText) { } catch (IOException e1) { Activator.logError(NLS.bind( UIText.BranchSelectionDialog_ErrorCouldNotResolve, testFor), e1); + return e1.getMessage(); } if (!Repository.isValidRefName(testFor)) return UIText.BranchSelectionDialog_ErrorInvalidRefName; @@ -332,27 +333,28 @@ public void widgetSelected(SelectionEvent e) { try { RefRename renameRef = repo.renameRef(refName, newRefName); if (renameRef.rename() != Result.RENAMED) { - MessageDialog.openError(getShell(), - "Rename failed", - NLS.bind(UIText.BranchSelectionDialog_ErrorCouldNotRenameRef, - new Object[] { refName, newRefName, renameRef.getResult() })); - Activator.logError(NLS.bind( - UIText.BranchSelectionDialog_ErrorCouldNotRenameRef2, - new Object[] { refName, newRefName }), null); + reportError( + null, + UIText.BranchSelectionDialog_BranchSelectionDialog_RenamedFailedTitle, + UIText.BranchSelectionDialog_ErrorCouldNotRenameRef, + refName, newRefName, renameRef + .getResult()); } - // FIXME: Update HEAD - } catch (IOException e1) { - Activator.logError(NLS.bind( - UIText.BranchSelectionDialog_ErrorCouldNotRenameRef2, - newRefName), e1); + } catch (Throwable e1) { + reportError( + e1, + UIText.BranchSelectionDialog_BranchSelectionDialog_RenamedFailedTitle, + UIText.BranchSelectionDialog_ErrorCouldNotRenameRef, + refName, newRefName, e1.getMessage()); } try { branchTree.removeAll(); fillTreeWithBranches(newRefName); - } catch (IOException e1) { - Activator.logError( - UIText.BranchSelectionDialog_ErrorCouldNotRefreshBranchList, - e1); + } catch (Throwable e1) { + reportError( + e1, + UIText.BranchSelectionDialog_BranchSelectionDialog_RenamedFailedTitle, + UIText.BranchSelectionDialog_ErrorCouldNotRefreshBranchList); } } } @@ -387,18 +389,20 @@ public void widgetSelected(SelectionEvent e) { updateRef.setNewObjectId(startAt); updateRef.setRefLogMessage("branch: Created from " + startBranch, false); updateRef.update(); - } catch (IOException e1) { - Activator.logError(NLS.bind( + } catch (Throwable e1) { + reportError( + e1, + UIText.BranchSelectionDialog_BranchSelectionDialog_CreateFailedTitle, UIText.BranchSelectionDialog_ErrorCouldNotCreateNewRef, - newRefName), e1); + newRefName); } try { branchTree.removeAll(); fillTreeWithBranches(newRefName); - } catch (IOException e1) { - Activator.logError( - UIText.BranchSelectionDialog_ErrorCouldNotRefreshBranchList, - e1); + } catch (Throwable e1) { + reportError(e1, + UIText.BranchSelectionDialog_BranchSelectionDialog_CreateFailedTitle, + UIText.BranchSelectionDialog_ErrorCouldNotRefreshBranchList); } } } @@ -419,4 +423,11 @@ createButton(parent, IDialogConstants.OK_ID, protected int getShellStyle() { return super.getShellStyle() | SWT.RESIZE; } + + private void reportError(Throwable e, String title, String message, + Object... args) { + String msg = NLS.bind(message, args); + MessageDialog.openError(getShell(), title, msg); + Activator.logError(msg, e); + } } diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties index f19db60..93ce3c9 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties @@ -333,6 +333,8 @@ WindowCachePreferencePage_packedGitMMAP=Use virtual memory mapping 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} -- 1.6.3.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html