I spent a good few hours this morning trying to make this work and
came up with the following patch. It's not quite right though.
The exception I've created exists in the libnbdmod module (ie. the
underlying C module that we use for the Python bindings). Ideally
we'd define and throw an exception from the normal nbd module, but I
couldn't work out how to do that.
Probably someone who knows a bit more about Python might find this
easy to do.
Rich.