diff --git a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Exceptions/ExceptionManager.cs b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Exceptions/ExceptionManager.cs index c228dd677..b525cbed6 100644 --- a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Exceptions/ExceptionManager.cs +++ b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Exceptions/ExceptionManager.cs @@ -45,6 +45,7 @@ internal static class ExceptionManager { typeof(ResultConsumedException), "ResultConsumedError" }, { typeof(TransactionNestingException), "TransactionNestingException" }, { typeof(TokenExpiredException), "TokenExpiredError" }, + { typeof(ConnectionReadTimeoutException), "ConnectionReadTimeoutError"}, { typeof(NotSupportedException), "NotSupportedException" } }; diff --git a/Neo4j.Driver/Neo4j.Driver.Tests/Extensions/StreamExtensionTests.cs b/Neo4j.Driver/Neo4j.Driver.Tests/Extensions/StreamExtensionTests.cs index 1d7a51943..9418dbcf5 100644 --- a/Neo4j.Driver/Neo4j.Driver.Tests/Extensions/StreamExtensionTests.cs +++ b/Neo4j.Driver/Neo4j.Driver.Tests/Extensions/StreamExtensionTests.cs @@ -33,7 +33,7 @@ public async Task ShouldReadAndThrowOnTimeout() ex.Should().NotBeNull(); ex.Should() - .BeOfType() + .BeOfType() .Which.Message.Should() .Be($"Socket/Stream timed out afer {timeout}ms, socket closed."); } diff --git a/Neo4j.Driver/Neo4j.Driver/Internal/Extensions/StreamExtensions.cs b/Neo4j.Driver/Neo4j.Driver/Internal/Extensions/StreamExtensions.cs index dbdcb10f7..587e99bd3 100644 --- a/Neo4j.Driver/Neo4j.Driver/Internal/Extensions/StreamExtensions.cs +++ b/Neo4j.Driver/Neo4j.Driver/Internal/Extensions/StreamExtensions.cs @@ -86,7 +86,7 @@ public static async Task ReadWithTimeoutAsync(this Stream stream, byte[] bu if (cancellationDelayTask.IsCanceled || cancellationDelayTask.IsCompleted) { stream.Close(); - throw new ServiceUnavailableException($"Socket/Stream timed out afer {timeoutMS}ms, socket closed."); + throw new ConnectionReadTimeoutException($"Socket/Stream timed out afer {timeoutMS}ms, socket closed."); } // Means that main task completed. We use Result directly. diff --git a/Neo4j.Driver/Neo4j.Driver/Neo4jException.cs b/Neo4j.Driver/Neo4j.Driver/Neo4jException.cs index 95975d1ae..c8bbfcbfb 100644 --- a/Neo4j.Driver/Neo4j.Driver/Neo4jException.cs +++ b/Neo4j.Driver/Neo4j.Driver/Neo4jException.cs @@ -263,11 +263,35 @@ public SessionExpiredException(string message, Exception innerException) : base( } } - /// - /// There was a bolt protocol violation of the contract between the driver and the server. - /// When seen this error, contact driver developers. - /// - [DataContract] + /// + /// A indicates that the driver timed out trying to read from the network socket. + /// + [DataContract] + public class ConnectionReadTimeoutException : Neo4jException + { + /// + /// Create a new with an error message. + /// + /// The error message. + public ConnectionReadTimeoutException(string message) : base(message) + { + } + + /// + /// Create a new with an error message and an exception. + /// + /// The error message. + /// The inner exception. + public ConnectionReadTimeoutException(string message, Exception innerException) : base(message, innerException) + { + } + } + + /// + /// There was a bolt protocol violation of the contract between the driver and the server. + /// When seen this error, contact driver developers. + /// + [DataContract] public class ProtocolException : Neo4jException { private const string ErrorCodeInvalid = "Neo.ClientError.Request.Invalid";