title: How to get the error code from BluetoothError
body: <p>I have this code for reading from a bluetooth socket:</p>
  
  <pre><code>socket.settimeout(timeout)
  try:
    data = socket.recv(1024)
  except bluetooth.btcommon.BluetoothError as e:
    if e.code == 11:
      self.connect()
  </code></pre>
  
  <p>obviously, I want to make a difference between a 'normal' timeout and some other problems (for example the bluetooth device switching off). The code above does not work because there is no <code>code</code> in the <code>BluetoothError</code> object.</p>
  
  <p>In the exception, I do see a code though:</p>
  
  <pre><code>Traceback (most recent call last):
    File "myscript.py", line 36, in scan
      data = socket.recv(1024)
    File "&lt;string&gt;", line 5, in recv
  bluetooth.btcommon.BluetoothError: (11, 'Resource temporarily unavailable')
  </code></pre>
  
  <p>How can I get that code? I tried looking for reference documentation online, but couldn't find anything.</p>
  
  <p>From the code, I can see it is in fact an <code>IOError</code>, and there doesn't seem to be a way to get the <code>errno</code>, is that correct?</p>