Skip to content

Commit

Permalink
Log GremlinQueryExecutionExceptions that happen upon a non-success st…
Browse files Browse the repository at this point in the history
…atus code.
  • Loading branch information
danielcweber committed Oct 9, 2024
1 parent 1f395bd commit f59f622
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Providers.Core/Factory/GremlinqClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Gremlin.Net.Driver.Exceptions;
using Gremlin.Net.Driver.Messages;

using Microsoft.Extensions.Logging;

using static Gremlin.Net.Driver.Messages.ResponseStatusCode;

namespace ExRam.Gremlinq.Providers.Core
Expand Down Expand Up @@ -219,7 +221,18 @@ static async IAsyncEnumerable<T> Core(GremlinQueryExecutorImpl @this, GremlinQue
switch (response)
{
case { Status: { Code: var code and not Success and not NoContent and not PartialContent and not Authenticate } status }:
throw new GremlinQueryExecutionException(context, new ResponseException(code, status.Attributes, $"{status.Code}: {status.Message}"));
{
try
{
throw new GremlinQueryExecutionException(context, new ResponseException(code, status.Attributes, $"{status.Code}: {status.Message}"));
}
catch (GremlinQueryExecutionException ex)
{
environment.Logger.LogError(ex, "Execution of Gremlin query {requestId} succeeded but returned response status code {statusCode}.", requestMessage.RequestId, code);

throw;
}
}
case { Result.Data: { } data }:
{
foreach (var obj in data)
Expand Down

0 comments on commit f59f622

Please sign in to comment.