diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2009-01-26 16:37:38 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2009-01-26 16:37:38 +0000 |
| commit | 2d430f5a920025dedcd3446ead153ee548e19ca9 (patch) | |
| tree | f57d8bab72c636b6ad41890e24817a8c0b675fa9 /java/management/eclipse-plugin/src | |
| parent | 1323f7832e1be3bd0819035651475198145e49ae (diff) | |
| download | qpid-python-2d430f5a920025dedcd3446ead153ee548e19ca9.tar.gz | |
QPID-1530 : Patch from Robert Gemmell to surpress StackTraces unless error is unknown.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@737741 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/management/eclipse-plugin/src')
| -rw-r--r-- | java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java | 74 |
1 files changed, 43 insertions, 31 deletions
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java index f74ab54cc3..202c6ea650 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java @@ -43,9 +43,8 @@ public class AbstractAction protected IWorkbenchWindow _window; - public static final String RMI_SASL_ERROR = "non-JRMP server"; - public static final String SECURITY_FAILURE = "User authentication has failed"; - public static final String SERVER_UNAVAILABLE = "Qpid server is not running"; + public static final String SECURITY_FAILURE = "User authentication failed"; + public static final String SERVER_UNAVAILABLE = "Unable to connect to the specified Qpid JMX server"; public static final String INVALID_PERSPECTIVE = "Invalid Perspective"; public static final String CHANGE_PERSPECTIVE = "Please use the Qpid Management Perspective"; @@ -73,10 +72,9 @@ public class AbstractAction return _navigationView; } - protected void handleException(Throwable ex, String title, String msg) { - MBeanUtility.printStackTrace(ex); + //ensure first that the exception is not due to running in the wrong eclipse perspective NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID); if (view == null) { @@ -85,48 +83,62 @@ public class AbstractAction ErrorDialog.openError(_window.getShell(), "Warning", INVALID_PERSPECTIVE, status); return; } + + //default title if none given + if (title == null) + { + title = ERROR_SERVER_CONNECTION; + } + + //determine the error message to display if (msg == null) { if (ex instanceof IOException) { - if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1)) - { - msg = SECURITY_FAILURE; - } - else - { - msg = SERVER_UNAVAILABLE; - } + //IOException, eg when trying to connect to a server/port with no JMX server running + msg = SERVER_UNAVAILABLE; + //Display error dialogue and return + displayErrorDialogue(msg, title); + return; } else if (ex instanceof SecurityException) { + //SecurityException when providing incorrect login credentials msg = SECURITY_FAILURE; + //Display error dialogue and return + displayErrorDialogue(msg, title); + return; } else { + //Unknown exception type/reason. msg = ex.getMessage(); } + + //if msg is still null, try reporting the cause. + if ((msg == null) && (ex.getCause() != null)) + { + msg = ex.getCause().getMessage(); + } + + //failing all else, default non-descript error message. + if (msg == null) + { + msg = "An unknown error has occured."; + } } - - if ((msg == null) && (ex.getCause() != null)) - { - msg = ex.getCause().getMessage(); - } - - if (msg == null) - { - msg = ERROR_SERVER_CONNECTION; - } - - if (title == null) - { - title = ERROR_SERVER_CONNECTION; - } - IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, - IStatus.OK, msg, null); - ErrorDialog.openError(_window.getShell(), "Error", title, status); + + //Display error dialogue and print the exception stack trace + MBeanUtility.printStackTrace(ex); + displayErrorDialogue(msg, title); } + private void displayErrorDialogue(String msg, String title) + { + IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, + IStatus.OK, msg, null); + ErrorDialog.openError(_window.getShell(), "Error", title, status); + } /** * Selection in the workbench has been changed. We can change the state of the 'real' action here |
