Clean up API-based parsing code in JS

* Move length check to ApiBasedValueParser, since it tries to take the first
  element afterwards
* Always return an Error, possibly RepoApiError in ParseValueCaller
* Stop passing the whole API response as HTML error message in some cases in
  ParseValueCaller
* Correctly pass error code in ParseValueCaller with bad data values
* Use RepoApiError for error message parsing in ParseValueCaller
* Don't try to find an error message in ApiBasedValueParser, since
  ParseValueCaller is doing that now
* Stop handling the response if promise has been rejected in ParseValueCaller

Change-Id: I2a93535469ebc3b7d850cf6c7d20bf54aa8066cd
Merge "Clean up API-based parsing code in JS"