From b70eeec9422ffe09bed954a817d070c759ee7354 Mon Sep 17 00:00:00 2001 From: Matt Weeks Date: Sat, 25 Jun 2011 03:53:32 +0000 Subject: [PATCH] Cleanup error messages; more descriptive and appropriate. git-svn-id: file:///home/svn/framework3/trunk@13021 4d416f70-5f16-0410-b530-b9f4589650da --- .../gui/msfguijava/src/msfgui/MainFrame.java | 8 ++++---- .../msfguijava/src/msfgui/MsfguiAboutBox.java | 1 - .../src/msfgui/OpenConnectionDialog.java | 6 ++++++ .../msfguijava/src/msfgui/RpcConnection.java | 18 ++++++++++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/external/source/gui/msfguijava/src/msfgui/MainFrame.java b/external/source/gui/msfguijava/src/msfgui/MainFrame.java index bd2014a081..63cc3177f5 100644 --- a/external/source/gui/msfguijava/src/msfgui/MainFrame.java +++ b/external/source/gui/msfguijava/src/msfgui/MainFrame.java @@ -116,7 +116,7 @@ public class MainFrame extends FrameView { connectRpc(); getFrame().addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { - if(!confirmStop()) + if(!MsfguiApp.shuttingDown && !confirmStop()) throw new RuntimeException("Closing aborted."); } }); @@ -137,13 +137,13 @@ public class MainFrame extends FrameView { return true; try { int choice = JOptionPane.showConfirmDialog(getFrame(), "Stop msfrpcd?"); + if(choice != JOptionPane.YES_OPTION && choice != JOptionPane.NO_OPTION) + return false; + MsfguiApp.shuttingDown = true; if(choice == JOptionPane.YES_OPTION) rpcConn.execute("core.stop"); else if(choice == JOptionPane.NO_OPTION) rpcConn.execute("auth.logout"); - else - return false; - MsfguiApp.shuttingDown = true; } catch (Exception ex) { } return true; diff --git a/external/source/gui/msfguijava/src/msfgui/MsfguiAboutBox.java b/external/source/gui/msfguijava/src/msfgui/MsfguiAboutBox.java index 621a2cda7c..c882b264d8 100644 --- a/external/source/gui/msfguijava/src/msfgui/MsfguiAboutBox.java +++ b/external/source/gui/msfguijava/src/msfgui/MsfguiAboutBox.java @@ -1,6 +1,5 @@ package msfgui; -import javax.swing.JOptionPane; import org.jdesktop.application.Action; /** diff --git a/external/source/gui/msfguijava/src/msfgui/OpenConnectionDialog.java b/external/source/gui/msfguijava/src/msfgui/OpenConnectionDialog.java index ed5573cf87..d1d0dd1e24 100644 --- a/external/source/gui/msfguijava/src/msfgui/OpenConnectionDialog.java +++ b/external/source/gui/msfguijava/src/msfgui/OpenConnectionDialog.java @@ -60,6 +60,12 @@ public class OpenConnectionDialog extends javax.swing.JDialog { if(mex.getMessage().toLowerCase().contains("authentication error")) mainframe.statusAnimationLabel.setText("Error authenticating; msfrpcd is running " +"but you did not enter the right credentials."); + else if (mex.getMessage().toLowerCase().contains("connection reset")) + mainframe.statusAnimationLabel.setText("Connection reset; is the SSL option correct?" + + " Is msfrpcd running on the right port?"); + else if (mex.getMessage().toLowerCase().contains("timed out")) + mainframe.statusAnimationLabel.setText("Timeout; is the SSL option correct?" + + " Is msfrpcd running on the right port?"); } catch (NullPointerException nex) {//generated when attributes dont exist. } //Darn. open the gui anyway diff --git a/external/source/gui/msfguijava/src/msfgui/RpcConnection.java b/external/source/gui/msfguijava/src/msfgui/RpcConnection.java index c8df51e0d1..ce4aba010a 100644 --- a/external/source/gui/msfguijava/src/msfgui/RpcConnection.java +++ b/external/source/gui/msfguijava/src/msfgui/RpcConnection.java @@ -71,9 +71,9 @@ public class RpcConnection { rpcToken=results.get("token").toString(); haveRpcd=results.get("result").equals("success"); } catch (MsfException xre) { - message = xre.getLocalizedMessage(); + message = xre.getLocalizedMessage(); } catch (IOException io){ - message = io.getLocalizedMessage(); + message = io.getLocalizedMessage(); } catch (NullPointerException nex){ } catch (NoSuchAlgorithmException nsax){ } catch (KeyManagementException kmx){ @@ -197,8 +197,10 @@ public class RpcConnection { ex = ex2; } if(! (ex instanceof MsfException)){ - ex.printStackTrace(); - throw new MsfException("Error in call: "+ex.getLocalizedMessage(), ex); + if(! MsfguiApp.shuttingDown || !ex.getLocalizedMessage().toLowerCase().contains("broken pipe")){ + ex.printStackTrace(); + throw new MsfException("Error in call: "+ex.getLocalizedMessage(), ex); + } } throw (MsfException)ex; } @@ -423,6 +425,14 @@ public class RpcConnection { mex.printStackTrace(); setMessage("Cannot connect to started msfrpcd."); throw mex; + }else if(mex.getMessage().toLowerCase().contains("connection reset")){ + mex.printStackTrace(); + setMessage("Connection reset."); + throw mex; + }else if(mex.getMessage().toLowerCase().contains("timed out")){ + mex.printStackTrace(); + setMessage("Timeout."); + throw mex; } } try {