fix error throwing logic

Just a simple typo fix!