RuntimeException (RemoteException e) { Throwable t = e.getCause(); while (t != null) { if (t instanceof SocketException || t instanceof EOFException) { throw new DebuggerStoppedException(); } t = t.getCause(); } return e.getCause() instanceof RuntimeException ? (RuntimeException)e.getCause() : new RuntimeException(e); }