Rework exception handling.

All bare 'except:' clauses have been removed, bar one which is a hack
anyway. Most of them have been replaced with 'except Exception:', but
some have been given more specific exceptions to catch. This may well
break code; if unexpected exceptions start bubbling up, that probably
indicates a need for an exception to this exception handling style :)