Cleanup error messages; more descriptive and appropriate.

git-svn-id: file:///home/svn/framework3/trunk@13021 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Matt Weeks 2011-06-25 03:53:32 +00:00
parent 73137c8dc1
commit b70eeec942
4 changed files with 24 additions and 9 deletions

View File

@ -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;

View File

@ -1,6 +1,5 @@
package msfgui;
import javax.swing.JOptionPane;
import org.jdesktop.application.Action;
/**

View File

@ -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

View File

@ -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 {