use of com.couchbase.client.core.error.context.SearchErrorContext in project couchbase-jvm-clients by couchbase.
the class SearchChunkResponseParser method errorsToThrowable.
private CouchbaseException errorsToThrowable(final byte[] bytes) {
int statusCode = responseHeader().status().code();
String errorDecoded = bytes == null || bytes.length == 0 ? "" : new String(bytes, CharsetUtil.UTF_8);
SearchErrorContext errorContext = new SearchErrorContext(HttpProtocol.decodeStatus(responseHeader().status()), requestContext(), statusCode, errorDecoded);
if (statusCode == 400 && errorDecoded.contains("index not found")) {
return new IndexNotFoundException(errorContext);
} else if (statusCode == 500) {
return new InternalServerFailureException(errorContext);
} else if (statusCode == 401 || statusCode == 403) {
return new AuthenticationFailureException("Could not authenticate search query", errorContext, null);
} else if (statusCode == 400 && errorDecoded.contains("num_fts_indexes")) {
return new QuotaLimitedException(errorContext);
} else if (statusCode == 429) {
if (errorDecoded.contains("num_concurrent_requests") || errorDecoded.contains("num_queries_per_min") || errorDecoded.contains("ingress_mib_per_min") || errorDecoded.contains("egress_mib_per_min")) {
return new RateLimitedException(errorContext);
}
}
return new CouchbaseException("Unknown search error: " + errorDecoded, errorContext);
}
Aggregations