Fix possible bad exception handling