Raise API error correctly on login failure.