Minimise the try block in error_for_oserror