summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-04-29 10:36:22 +0200
committerJon Bratseth <bratseth@verizonmedia.com>2019-04-29 10:36:22 +0200
commit2a41f5af6f9c83b4305a4bb01dd9fd1901c24577 (patch)
tree6745547aa07fc9280862a36cefb59ca3ab95a1d7 /vespaclient-container-plugin
parent086cb954dfd88caaa4e7998e4e3d8cd052db7907 (diff)
Revert "Merge pull request #9207 from vespa-engine/revert-9204-bratseth/document-api-donct-blame-users"
This reverts commit 3575ceec65b3787a4f3e412c86479c79cf1d6453, reversing changes made to e535c8fa9c1264d7164fef7f55d10dc585e13e88.
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java
index 873b0569553..6fed0dff36d 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java
@@ -36,6 +36,7 @@ import com.yahoo.vespaclient.ClusterList;
import com.yahoo.vespaxmlparser.DocumentFeedOperation;
import com.yahoo.vespaxmlparser.FeedOperation;
import com.yahoo.vespaxmlparser.VespaXMLFeedReader;
+import com.yahoo.yolean.Exceptions;
import java.io.IOException;
import java.io.OutputStream;
@@ -230,10 +231,14 @@ public class RestApi extends LoggingRequestHandler {
}
} catch (RestApiException e) {
return e.getResponse();
- } catch (Exception e2) {
- // We always blame the user. This might be a bit nasty, but the parser throws various kind of exception
- // types, but with nice descriptions.
- return Response.createErrorResponse(400, e2.getMessage(), restUri, RestUri.apiErrorCodes.PARSER_ERROR);
+ } catch (IllegalArgumentException userException) {
+ return Response.createErrorResponse(400, Exceptions.toMessageString(userException),
+ restUri,
+ RestUri.apiErrorCodes.PARSER_ERROR);
+ } catch (RuntimeException systemException) {
+ return Response.createErrorResponse(500, Exceptions.toMessageString(systemException),
+ restUri,
+ RestUri.apiErrorCodes.PARSER_ERROR);
}
return new Response(200, resultJson, Optional.of(restUri));
}
@@ -401,8 +406,8 @@ public class RestApi extends LoggingRequestHandler {
} catch (BadRequestParameterException e) {
return createInvalidParameterResponse(e.getParameter(), e.getMessage());
}
- final OperationHandler.VisitResult visit = operationHandler.visit(restUri, documentSelection, options);
- final ObjectNode resultNode = mapper.createObjectNode();
+ OperationHandler.VisitResult visit = operationHandler.visit(restUri, documentSelection, options);
+ ObjectNode resultNode = mapper.createObjectNode();
visit.token.ifPresent(t -> resultNode.put(CONTINUATION, t));
resultNode.putArray(DOCUMENTS).addPOJO(visit.documentsAsJsonList);
resultNode.put(PATH_NAME, restUri.getRawPath());