Fix error due to bad exception throwing