Skip to content

Commit 42096ef

Browse files
author
Nuno Chaves
authored
Merge pull request #10 from TCB13/master
Better query error handling.
2 parents 43784e5 + 9ecc9c5 commit 42096ef

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/CosmosDb.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,12 @@ public function query($rid_id, $rid_col, $query, $isCrossPartition = false)
202202
// This is a first chance (internal) exception that all newer clients will know how to
203203
// handle gracefully. This exception is traced, but unless you see it bubble up as an
204204
// exception (which only happens on older SDK clients), then you can safely ignore this message.
205-
if ($responseError->code === "BadRequest" && $isCrossPartition) {
205+
if ($isCrossPartition && $responseError->code === "BadRequest" && strpos($responseError->message, "cross partition query can not be directly served by the gateway") !== false) {
206206
$headers["x-ms-documentdb-partitionkeyrangeid"] = $this->getPkFullRange($rid_id, $rid_col);
207207
$result = $this->request("/dbs/" . $rid_id . "/colls/" . $rid_col . "/docs", "POST", $headers, $query);
208+
} else {
209+
throw $e;
208210
}
209-
210211
}
211212

212213
return $result;

0 commit comments

Comments
 (0)