tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [2/5] tinkerpop git commit: TINKERPOP-1044: Standardized Message Format and Added Extra HTTP Header for the exception class instead of making a message with multiple lines
Date Fri, 07 Oct 2016 22:34:03 GMT
TINKERPOP-1044: Standardized Message Format and Added Extra HTTP Header for the exception class
instead of making a message with multiple lines


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3202db1b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3202db1b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3202db1b

Branch: refs/heads/master
Commit: 3202db1b14f80d09f95bbb692844e9f91f66b925
Parents: de9bbda
Author: Vivek Krishnan <vikri@microsoft.com>
Authored: Wed Sep 28 11:06:14 2016 -0700
Committer: Vivek Krishnan <vikri@microsoft.com>
Committed: Wed Sep 28 11:06:14 2016 -0700

----------------------------------------------------------------------
 .../handler/HttpGremlinEndpointHandler.java     | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3202db1b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
index a30c30e..96861bb 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
@@ -254,18 +254,9 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter
{
 
                 evalFuture.exceptionally(t -> {
 					
-					if (t.getMessage() != null) {
-						sendError(ctx, INTERNAL_SERVER_ERROR,
-								String.format("Error encountered evaluating script: %s\nExecution Interrupted by
%s\nMessage: %s", 
-											  requestArguments.getValue0(), t.getClass().getName(), t.getMessage()),
-								Optional.of(t));
-                    } else {
-						sendError(ctx, INTERNAL_SERVER_ERROR,
-								String.format("Error encountered evaluating script: %s\nExecution Interrupted by
%s", 
-											  requestArguments.getValue0(), t.getClass().getName()),
-								Optional.of(t));
-					}
-					
+					String errorMessage = (t.getMessage() != null) ? t.getMessage() : 
+										String.format("Error encountered evaluating script: %s", requestArguments.getValue0());
+					sendError(ctx, INTERNAL_SERVER_ERROR, errorMessage, Optional.of(t));
                     promise.setFailure(t);
                     return null;
                 });
@@ -465,6 +456,11 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter
{
         errorMeter.mark();
         final ObjectNode node = mapper.createObjectNode();
         node.put("message", message);
+		if (t.isPresent()){
+			node.put("Exception-Class", t.get().getClass().getName());
+		}
+		
+		
         final FullHttpResponse response = new DefaultFullHttpResponse(
                 HTTP_1_1, status, Unpooled.copiedBuffer(node.toString(), CharsetUtil.UTF_8));
         response.headers().set(CONTENT_TYPE, "application/json");


Mime
View raw message