Query throws error, getting in my way

Discussion created by odoe on May 23, 2014
So I have a few FeatureLayers in selection mode.
They all share a common field, let's say "FEATURE_ID". One of the layers also has a field called "MAIN_FEATURE_ID".
So I give a query like so.

      var q = new Query();
      q.where = "FEATURE_ID = '" + featureid +
        "' OR MAIN_FEATURE_ID = '" + featureid + "'";

Now, I know that query is going to error out on 2 of my 3 FeatureLayers because only 1 has that second field. I don't care, that's what the error handler callbacks are for.

So I do something like this for my FeatureLayers
      var queries = arrayUtils.map(this.get('featureLayers'), function(lyr) {
        return lyr.selectFeatures(q, FeatureLayer.SELECTION_NEW);
      }, this);

Then I use dojo/promise/all to get all the data when everything is done.
      all(queries).then(lang.hitch(this, function(results) {
        var data = [];
        data = data.concat.apply(data, results);
        if (merged.length) {
      }), function(err) { // capture the errors here
        console.debug('error', err);

What is happening here is that my error prints to console, but the API is throwing an internal error
Error {code: 400, message: "Unable to complete operation.", details: Array[0], log: undefined, httpCode: 400???} init.js:187

This breaks something because not my success function doesn't get called either.

If I check the network trace in Chrome dev tools, I can see the queries and responses, 2 of the requests return an error code of 400, but the last one returns valid results, but something is blocking that result from bubbling up to my success call.

If I change the query to only search the one common field, everything is fine.

Any clues?

I tried adding my own Deferred and returning the Deferred#promise and capturing the error, thinking maybe there was a quirk in dojo/promise/all
      var queries = arrayUtils.map(this.get('featureLayers'), function(lyr) {
        var def = new Deferred();
        lyr.selectFeatures(q, FeatureLayer.SELECTION_NEW).then(function(response) {
        }, function(err) {
          console.debug('query error', err);
        return def.promise;
      }, this);

Still no good. It looks like the errors the API throws are killing my success function. I know I'm going to get errors, I'll deal with it, but is this the intended behavior?