properly handle error codes other than 200 from api server

see #912