use of org.neo4j.bolt.runtime.Neo4jError in project neo4j by neo4j.
the class ErrorReporterTest method onlyDatabaseErrorsAreLogged.
@Test
void onlyDatabaseErrorsAreLogged() {
AssertableLogProvider userLog = new AssertableLogProvider();
AssertableLogProvider internalLog = new AssertableLogProvider();
ErrorReporter reporter = newErrorReporter(userLog, internalLog);
for (Status.Classification classification : Status.Classification.values()) {
if (classification != Status.Classification.DatabaseError) {
Status.Code code = newStatusCode(classification);
Neo4jError error = Neo4jError.from(() -> code, "Database error");
reporter.report(error);
assertThat(userLog).doesNotHaveAnyLogs();
assertThat(internalLog).doesNotHaveAnyLogs();
}
}
}
use of org.neo4j.bolt.runtime.Neo4jError in project neo4j by neo4j.
the class AbstractBoltStateMachine method handleFailure.
@Override
public void handleFailure(Throwable cause, boolean fatal) throws BoltConnectionFatality {
if (ExceptionUtils.indexOfType(cause, BoltConnectionFatality.class) != -1) {
fatal = true;
}
Neo4jError error = fatal ? Neo4jError.fatalFrom(cause) : Neo4jError.from(cause);
fail(error);
if (error.isFatal()) {
if (ExceptionUtils.indexOfType(cause, AuthorizationExpiredException.class) != -1) {
throw new BoltConnectionAuthFatality("Failed to process a bolt message", cause);
}
if (cause instanceof AuthenticationException) {
throw new BoltConnectionAuthFatality((AuthenticationException) cause);
}
throw new BoltConnectionFatality("Failed to process a bolt message", cause);
}
}
use of org.neo4j.bolt.runtime.Neo4jError in project neo4j by neo4j.
the class AbstractBoltStateMachine method after.
protected void after() {
if (connectionState.getResponseHandler() != null) {
try {
Neo4jError pendingError = connectionState.getPendingError();
if (pendingError != null) {
connectionState.markFailed(pendingError);
}
if (connectionState.hasPendingIgnore()) {
connectionState.markIgnored();
}
connectionState.resetPendingFailedAndIgnored();
connectionState.getResponseHandler().onFinish();
} finally {
connectionState.setResponseHandler(null);
}
}
}
use of org.neo4j.bolt.runtime.Neo4jError in project neo4j by neo4j.
the class ErrorReporterTest method databaseErrorShouldLogFullMessageInDebugLogAndHelpfulPointerInUserLog.
@Test
void databaseErrorShouldLogFullMessageInDebugLogAndHelpfulPointerInUserLog() {
// given
AssertableLogProvider userLog = new AssertableLogProvider();
AssertableLogProvider internalLog = new AssertableLogProvider();
ErrorReporter reporter = newErrorReporter(userLog, internalLog);
Neo4jError error = Neo4jError.fatalFrom(new TestDatabaseError());
UUID reference = error.reference();
// when
reporter.report(error);
// then
assertThat(userLog).containsMessages("Client triggered an unexpected error", reference.toString(), "Database error");
assertThat(internalLog).containsMessages(reference.toString(), "Database error");
}
use of org.neo4j.bolt.runtime.Neo4jError in project neo4j by neo4j.
the class BoltStateMachineV4Test method testMarkFailedShouldYieldSuccessIfAlreadyFailed.
private static void testMarkFailedShouldYieldSuccessIfAlreadyFailed(ThrowingBiConsumer<BoltStateMachine, BoltResponseHandler, BoltConnectionFatality> action) throws Exception {
// Given
BoltStateMachine machine = init(newMachine());
machine.markFailed(Neo4jError.from(new RuntimeException()));
BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
machine.markFailed(error);
// When
action.accept(machine, responseHandler);
// Expect
assertNull(pendingError(machine));
assertFalse(pendingIgnore(machine));
assertThat(machine).satisfies(inState(ReadyState.class));
verify(responseHandler, never()).markIgnored();
verify(responseHandler, never()).markFailed(any());
}
Aggregations