throw exception if an error exists