private void AssertYieldsErrors(string json, params Neo4jError[] expectedErrors) { StatementDeserializer de = new StatementDeserializer(new ByteArrayInputStreamAnonymousInnerClass(this, UTF8.encode(json))); while (de.MoveNext()) { de.Current; } IEnumerator <Neo4jError> actual = de.Errors(); IEnumerator <Neo4jError> expected = asList(expectedErrors).GetEnumerator(); while (actual.MoveNext()) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue(expected.hasNext()); Neo4jError error = actual.Current; //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Neo4jError expectedError = expected.next(); assertThat(error.Message, equalTo(expectedError.Message)); assertThat(error.Status(), equalTo(expectedError.Status())); } //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(expected.hasNext()); }
private void PublishError(BoltResponseMessageWriter messageWriter, Neo4jError error) { try { if (error.Fatal) { messageWriter.Write(new FatalFailureMessage(error.Status(), error.Message())); } else { messageWriter.Write(new FailureMessage(error.Status(), error.Message())); } } catch (PackOutputClosedException e) { // Can't write error to the client, because the connection is closed. // Very likely our error is related to the connection being closed. // If the error is that the transaction was terminated, then the error is a side-effect of // us cleaning up stuff that was running when the client disconnected. Log a warning without // stack trace to highlight clients are disconnecting while stuff is running: if (_clientMidOpDisconnectErrors.Contains(error.Status())) { Log.warn("Client %s disconnected while query was running. Session has been cleaned up. " + "This can be caused by temporary network problems, but if you see this often, " + "ensure your applications are properly waiting for operations to complete before exiting.", e.ClientAddress()); return; } // If the error isn't that the tx was terminated, log it to the console for debugging. It's likely // there are other "ok" errors that we can whitelist into the conditional above over time. Log.warn("Unable to send error back to the client. " + e.Message, error.Cause()); } catch (Exception t) { // some unexpected error happened while writing exception back to the client // log it together with the original error being suppressed t.addSuppressed(error.Cause()); Log.error("Unable to send error back to the client", t); } }