title: How do I catch SocketExceptions in MonkeyRunner?
body: <p>When using MonkeyRunner, every so often I get an error like:</p>
  
  <pre><code>120830 18:39:32.755:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] Unable to get variable: display.density
  120830 18:39:32.755:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Connection reset
  </code></pre>
  
  <p>From what I've read, sometimes the adb connection goes bad, and you need to reconnect. The only problem is, I'm not able to catch the <code>SocketException</code>. I'll wrap my code like so:</p>
  
  <pre><code>try:
      density = self.device.getProperty('display.density')
  except:
      print 'This will never print.'
  </code></pre>
  
  <p>But the exception is apparently not raised all the way to the caller. I've verified that MonkeyRunner/jython can catch Java exceptions the way I'd expect:</p>
  
  <pre><code>&gt;&gt;&gt; from java.io import FileInputStream
  &gt;&gt;&gt; def test_java_exceptions():
  ...     try:
  ...         FileInputStream('bad mojo')
  ...     except:
  ...         print 'Caught it!'
  ...
  &gt;&gt;&gt; test_java_exceptions()
  Caught it!
  </code></pre>
  
  <p>How can I deal with these socket exceptions?</p>