Adds StatusCode (of type ResponseStatusCode) property on ResponseException.


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

Branch: refs/heads/TINKERPOP-1913
Commit: 0735f9a6055c00f2c962b359042328dc59c6d33a
Parents: adaf173
Author: Patrik Husfloen <re...@redoz.com>
Authored: Sat Sep 8 16:54:11 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:34:38 2018 -0400

----------------------------------------------------------------------
 .../Driver/Exceptions/ResponseException.cs      | 16 +++++--
 .../Driver/Messages/ResponseStatus.cs           |  2 +-
 .../Driver/Messages/ResponseStatusCode.cs       | 48 +++++++++++++++++++-
 3 files changed, 61 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0735f9a6/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
----------------------------------------------------------------------
diff --git 
a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs 
b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
index 3c0d927..f9020d2 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
@@ -23,6 +23,7 @@
 
 using System;
 using System.Collections.Generic;
+using Gremlin.Net.Driver.Messages;
 
 namespace Gremlin.Net.Driver.Exceptions
 {
@@ -34,15 +35,24 @@ namespace Gremlin.Net.Driver.Exceptions
         /// <summary>
         ///     Initializes a new instance of the <see 
cref="ResponseException" /> class.
         /// </summary>
-        /// <param name="statusAttributes">The status attributes as returned 
by the server.</param>
+        /// <param name="statusCode">The status code returned by the 
server.</param>
+        /// <param name="statusAttributes">The status attributes from the 
gremlin response.</param>
         /// <param name="message">The error message string.</param>
-        public ResponseException(IReadOnlyDictionary<string, object> 
statusAttributes, string message) : base(message)
+        public ResponseException(ResponseStatusCode statusCode,
+                                 IReadOnlyDictionary<string, object> 
statusAttributes,
+                                 string message) : base(message)
         {
             StatusAttributes = statusAttributes;
+            StatusCode = statusCode;
         }
 
         /// <summary>
-        /// Gets or sets the status attributes from the gremlin response
+        /// Gets the status code returned from the server.
+        /// </summary>
+        public ResponseStatusCode StatusCode { get; }
+
+        /// <summary>
+        /// Gets the status attributes from the gremlin response
         /// </summary>
         public IReadOnlyDictionary<string, object> StatusAttributes { get; }
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0735f9a6/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs 
b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
index c436662..aa0b1b7 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
@@ -44,7 +44,7 @@ namespace Gremlin.Net.Driver.Messages
         public static void ThrowIfStatusIndicatesError(this ResponseStatus 
status)
         {
             if (status.Code.IndicatesError())
-                throw new ResponseException(status.Attributes, 
$"{status.Code}: {status.Message}");
+                throw new ResponseException(status.Code, status.Attributes, 
$"{status.Code}: {status.Message}");
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0735f9a6/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
----------------------------------------------------------------------
diff --git 
a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs 
b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
index 558e4f6..1c5d088 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
@@ -25,18 +25,64 @@ using System;
 
 namespace Gremlin.Net.Driver.Messages
 {
-    internal enum ResponseStatusCode
+    /// <summary>
+    /// Represents the various status codes that Gremlin Server returns.
+    /// </summary>
+    public enum ResponseStatusCode
     {
+        /// <summary>
+        /// The server successfully processed a request to completion - there 
are no messages remaining in this stream.
+        /// </summary>
         Success = 200,
+        
+        /// <summary>
+        /// The server processed the request but there is no result to return 
(e.g. an Iterator with no elements) - there are no messages remaining in this 
stream.
+        /// </summary>
         NoContent = 204,
+        
+        /// <summary>
+        /// The server successfully returned some content, but there is more 
in the stream to arrive - wait for a SUCCESS to signify the end of the stream.
+        /// </summary>
         PartialContent = 206,
+
+        /// <summary>
+        /// The request attempted to access resources that the requesting user 
did not have access to.
+        /// </summary>
         Unauthorized = 401,
+
+        /// <summary>
+        /// A challenge from the server for the client to authenticate its 
request.
+        /// </summary>
         Authenticate = 407,
+
+        /// <summary>
+        /// The request message was not properly formatted which means it 
could not be parsed at all or the "op" code was not recognized such that 
Gremlin Server could properly route it for processing. Check the message format 
and retry the request.
+        /// </summary>
         MalformedRequest = 498,
+
+        /// <summary>
+        /// The request message was parseable, but the arguments supplied in 
the message were in conflict or incomplete. Check the message format and retry 
the request.
+        /// </summary>
         InvalidRequestArguments = 499,
+
+        /// <summary>
+        /// A general server error occurred that prevented the request from 
being processed.
+        /// </summary>
         ServerError = 500,
+
+        /// <summary>
+        /// The script submitted for processing evaluated in the ScriptEngine 
with errors and could not be processed. Check the script submitted for syntax 
errors or other problems and then resubmit.
+        /// </summary>
         ScriptEvaluationError = 597,
+
+        /// <summary>
+        /// The server exceeded one of the timeout settings for the request 
and could therefore only partially responded or did not respond at all.
+        /// </summary>
         ServerTimeout = 598,
+
+        /// <summary>
+        /// The server was not capable of serializing an object that was 
returned from the script supplied on the request. Either transform the object 
into something Gremlin Server can process within the script or install mapper 
serialization classes to Gremlin Server.
+        /// </summary>
         ServerSerializationError = 599
     }
 

Reply via email to