-
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🥅 andle MongoDB errors 168 (InvalidPipelineOperator), 17276 (Use of u…
…ndefined variable), 17287+31254 (Cannot do exclusion in inclusion projection) to return status code 400
- Loading branch information
Showing
2 changed files
with
24 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,6 @@ | |
|
||
import java.util.Optional; | ||
|
||
import com.mongodb.MongoException; | ||
import io.undertow.server.HttpServerExchange; | ||
import org.bson.BsonArray; | ||
import org.bson.BsonDocument; | ||
import org.bson.json.JsonParseException; | ||
|
@@ -37,6 +35,8 @@ | |
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.undertow.server.HttpServerExchange; | ||
|
||
/** | ||
* | ||
* @author Andrea Di Cesare {@literal <[email protected]>} | ||
|
@@ -114,30 +114,19 @@ public void handleRequest(HttpServerExchange exchange) throws Exception { | |
return; | ||
} | ||
|
||
try { | ||
data = dbs.getCollectionData( | ||
Optional.ofNullable(request.getClientSession()), | ||
request.rsOps(), | ||
request.getDBName(), | ||
request.getCollectionName(), | ||
request.getPage(), | ||
request.getPagesize(), | ||
sort, | ||
filter, | ||
request.getHintDocument(), | ||
request.getProjectionDocument(), | ||
request.isCache()); | ||
} catch (MongoException me) { | ||
if (me.getMessage().matches(".*Can't canonicalize query.*")) { | ||
// error with the filter expression during query execution | ||
LOGGER.debug("invalid filter expression {}", request.getFilter(), me); | ||
MongoResponse.of(exchange).setInError(HttpStatus.SC_BAD_REQUEST, "wrong request, filter expression is invalid", me); | ||
next(exchange); | ||
return; | ||
} else { | ||
throw me; | ||
} | ||
} | ||
data = dbs.getCollectionData( | ||
Optional.ofNullable(request.getClientSession()), | ||
request.rsOps(), | ||
request.getDBName(), | ||
request.getCollectionName(), | ||
request.getPage(), | ||
request.getPagesize(), | ||
sort, | ||
filter, | ||
request.getHintDocument(), | ||
request.getProjectionDocument(), | ||
request.isCache()); | ||
|
||
} | ||
|
||
if (exchange.isComplete()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters