Fixing type of exception thrown