Revision: 5021 http://tigervnc.svn.sourceforge.net/tigervnc/?rev=5021&view=rev Author: bphinz Date: 2012-12-16 20:35:39 +0000 (Sun, 16 Dec 2012) Log Message: ----------- Make exception handling more user friendly. Not all exceptions are 'errors' (for example, exiting the server intentionally via the window manager's logoff button).
Modified Paths: -------------- trunk/java/com/tigervnc/network/SocketDescriptor.java trunk/java/com/tigervnc/network/TcpListener.java trunk/java/com/tigervnc/network/TcpSocket.java trunk/java/com/tigervnc/rdr/FdOutStream.java trunk/java/com/tigervnc/rdr/TLSOutStream.java trunk/java/com/tigervnc/vncviewer/CConn.java trunk/java/com/tigervnc/vncviewer/VncViewer.java Modified: trunk/java/com/tigervnc/network/SocketDescriptor.java =================================================================== --- trunk/java/com/tigervnc/network/SocketDescriptor.java 2012-12-14 22:40:02 UTC (rev 5020) +++ trunk/java/com/tigervnc/network/SocketDescriptor.java 2012-12-16 20:35:39 UTC (rev 5021) @@ -39,13 +39,13 @@ writeSelector = Selector.open(); readSelector = Selector.open(); } catch (IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } try { channel.register(writeSelector, SelectionKey.OP_WRITE); channel.register(readSelector, SelectionKey.OP_READ); } catch (java.nio.channels.ClosedChannelException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } } @@ -54,7 +54,7 @@ channel.socket().shutdownInput(); channel.socket().shutdownOutput(); } catch(IOException e) { - throw new IOException(e.toString()); + throw new IOException(e.getMessage()); } } @@ -62,7 +62,7 @@ try { channel.close(); } catch(IOException e) { - throw new IOException(e.toString()); + throw new IOException(e.getMessage()); } } @@ -80,7 +80,7 @@ try { n = channel.read(b); } catch (java.io.IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } if (n <= 0) return (n == 0) ? -1 : 0; @@ -99,7 +99,7 @@ try { n = channel.write(b); } catch (java.io.IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } b.clear(); return n; @@ -129,7 +129,7 @@ } } } catch (java.io.IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } return n; } @@ -139,7 +139,7 @@ try { n = channel.write(buf); } catch (java.io.IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } return n; } @@ -151,7 +151,7 @@ try { n = channel.write(buf, offset, length); } catch (java.io.IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } return n; } @@ -161,7 +161,7 @@ try { n = channel.read(buf); } catch (java.io.IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } return n; } @@ -173,7 +173,7 @@ try { n = channel.read(buf, offset, length); } catch (java.io.IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } return n; } @@ -232,7 +232,7 @@ writeSelector = Selector.open(); readSelector = Selector.open(); } catch (java.io.IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } try { channel.register(writeSelector, SelectionKey.OP_WRITE); Modified: trunk/java/com/tigervnc/network/TcpListener.java =================================================================== --- trunk/java/com/tigervnc/network/TcpListener.java 2012-12-14 22:40:02 UTC (rev 5020) +++ trunk/java/com/tigervnc/network/TcpListener.java 2012-12-16 20:35:39 UTC (rev 5021) @@ -62,7 +62,7 @@ addr = InetAddress.getByName("0.0.0.0"); } } catch (UnknownHostException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } try { @@ -120,7 +120,7 @@ try { new_sock.socket().setTcpNoDelay(true); } catch (java.net.SocketException e) { - throw new SocketException(e.toString()); + throw new SocketException(e.getMessage()); } // Create the socket object & check connection is allowed @@ -128,7 +128,7 @@ try { fd = new SocketDescriptor(); } catch (java.lang.Exception e) { - throw new SocketException(e.toString()); + throw new SocketException(e.getMessage()); } fd.setChannel(new_sock); TcpSocket s = new TcpSocket(fd); Modified: trunk/java/com/tigervnc/network/TcpSocket.java =================================================================== --- trunk/java/com/tigervnc/network/TcpSocket.java 2012-12-14 22:40:02 UTC (rev 5020) +++ trunk/java/com/tigervnc/network/TcpSocket.java 2012-12-16 20:35:39 UTC (rev 5021) @@ -108,7 +108,7 @@ try { ((SocketDescriptor)getFd()).close(); } catch (IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } } @@ -148,7 +148,7 @@ SocketAddress myaddr = ((SocketDescriptor)getFd()).getLocalAddress(); return myaddr.equals(peeraddr); } catch (IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } } @@ -157,7 +157,7 @@ try { ((SocketDescriptor)getFd()).shutdown(); } catch (IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } } Modified: trunk/java/com/tigervnc/rdr/FdOutStream.java =================================================================== --- trunk/java/com/tigervnc/rdr/FdOutStream.java 2012-12-14 22:40:02 UTC (rev 5020) +++ trunk/java/com/tigervnc/rdr/FdOutStream.java 2012-12-16 20:35:39 UTC (rev 5021) @@ -107,7 +107,7 @@ n = fd.select(SelectionKey.OP_WRITE, tv); } catch (java.lang.Exception e) { System.out.println(e.toString()); - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } } while (n < 0); @@ -117,7 +117,7 @@ try { n = fd.write(data, dataPtr, length); } catch (java.lang.Exception e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } return n; Modified: trunk/java/com/tigervnc/rdr/TLSOutStream.java =================================================================== --- trunk/java/com/tigervnc/rdr/TLSOutStream.java 2012-12-14 22:40:02 UTC (rev 5020) +++ trunk/java/com/tigervnc/rdr/TLSOutStream.java 2012-12-16 20:35:39 UTC (rev 5021) @@ -79,7 +79,7 @@ try { n = manager.write(data, dataPtr, length); } catch (java.io.IOException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } //if (n == GNUTLS_E_INTERRUPTED || n == GNUTLS_E_AGAIN) // return 0; Modified: trunk/java/com/tigervnc/vncviewer/CConn.java =================================================================== --- trunk/java/com/tigervnc/vncviewer/CConn.java 2012-12-14 22:40:02 UTC (rev 5020) +++ trunk/java/com/tigervnc/vncviewer/CConn.java 2012-12-16 20:35:39 UTC (rev 5021) @@ -134,7 +134,7 @@ try { sock = new TcpSocket(serverHost, serverPort); } catch (java.lang.Exception e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } vlog.info("connected to host "+serverHost+" port "+serverPort); } @@ -177,7 +177,7 @@ wait(1); } } catch (java.lang.InterruptedException e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } } @@ -299,7 +299,7 @@ vlog.info("Redirected to "+host+":"+port); VncViewer.newViewer(viewer, sock, true); } catch (java.lang.Exception e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } } @@ -698,7 +698,7 @@ if (sock != null) sock.shutdown(); } catch (java.lang.Exception e) { - throw new Exception(e.toString()); + throw new Exception(e.getMessage()); } } Modified: trunk/java/com/tigervnc/vncviewer/VncViewer.java =================================================================== --- trunk/java/com/tigervnc/vncviewer/VncViewer.java 2012-12-14 22:40:02 UTC (rev 5020) +++ trunk/java/com/tigervnc/vncviewer/VncViewer.java 2012-12-16 20:35:39 UTC (rev 5021) @@ -371,12 +371,18 @@ while (!cc.shuttingDown) cc.processMsg(); } catch (java.lang.Exception e) { - if (cc == null || !cc.shuttingDown) { + if (e instanceof EndOfStream) { + vlog.info(e.getMessage()); + } else if (cc == null || !cc.shuttingDown) { e.printStackTrace(); - JOptionPane.showMessageDialog(null, - e.toString(), - "VNC Viewer : Error", - JOptionPane.ERROR_MESSAGE); + JOptionPane op = + new JOptionPane(e.getMessage(), JOptionPane.WARNING_MESSAGE); + JDialog dlg = op.createDialog("TigerVNC Viewer"); + ClassLoader cl = this.getClass().getClassLoader(); + ImageIcon icon = + new ImageIcon(cl.getResource("com/tigervnc/vncviewer/tigervnc.ico")); + dlg.setIconImage(icon.getImage()); + dlg.setVisible(true); } else { if (!cc.shuttingDown) vlog.info(e.toString()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Tigervnc-commits mailing list Tigervnc-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tigervnc-commits