Be more specific about which exceptions are thrown

--HG--
extra : amend_source : 31af9b64743917864dde5c1c0afed084b432f43b