handle api error - rough version = =