Skip to content

Commit 1b7ebd7

Browse files
author
Zhen Li
committed
Refining error message
1 parent 83d57d7 commit 1b7ebd7

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

driver/src/main/java/org/neo4j/driver/internal/async/ExplicitTransaction.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ public CompletionStage<Void> commitAsync()
104104
{
105105
if ( state == State.COMMITTED )
106106
{
107-
return failedFuture( new ClientException( "Can't commit, transaction has been committed" ) );
107+
return failedFuture( new ClientException( "Cannot commit, transaction has been committed" ) );
108108
}
109109
else if ( state == State.ROLLED_BACK )
110110
{
111-
return failedFuture( new ClientException( "Can't commit, transaction has been rolled back" ) );
111+
return failedFuture( new ClientException( "Cannot commit, transaction has been rolled back" ) );
112112
}
113113
else
114114
{
@@ -122,11 +122,11 @@ public CompletionStage<Void> rollbackAsync()
122122
{
123123
if ( state == State.COMMITTED )
124124
{
125-
return failedFuture( new ClientException( "Can't rollback, transaction has been committed" ) );
125+
return failedFuture( new ClientException( "Cannot rollback, transaction has been committed" ) );
126126
}
127127
else if ( state == State.ROLLED_BACK )
128128
{
129-
return failedFuture( new ClientException( "Can't rollback, transaction has been rolled back" ) );
129+
return failedFuture( new ClientException( "Cannot rollback, transaction has been rolled back" ) );
130130
}
131131
else
132132
{
@@ -190,7 +190,7 @@ private CompletionStage<Void> doCommitAsync()
190190
{
191191
if ( state == State.TERMINATED )
192192
{
193-
return failedFuture( new ClientException( "Transaction can't be committed. " +
193+
return failedFuture( new ClientException( "Transaction cannot be committed. " +
194194
"It has been rolled back either because of an error or explicit termination" ) );
195195
}
196196
return protocol.commitTransaction( connection ).thenAccept( bookmarkHolder::setBookmark );

driver/src/test/java/org/neo4j/driver/integration/ExplicitTransactionIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void shouldFailToCommitAfterRollback()
118118
assertNull( await( tx.rollbackAsync() ) );
119119

120120
ClientException e = assertThrows( ClientException.class, () -> await( tx.commitAsync() ) );
121-
assertEquals( "Can't commit, transaction has been rolled back", e.getMessage() );
121+
assertEquals( "Cannot commit, transaction has been rolled back", e.getMessage() );
122122
assertFalse( tx.isOpen() );
123123
}
124124

@@ -130,7 +130,7 @@ void shouldFailToCommitAfterTermination()
130130
tx.markTerminated();
131131

132132
ClientException e = assertThrows( ClientException.class, () -> await( tx.commitAsync() ) );
133-
assertThat( e.getMessage(), startsWith( "Transaction can't be committed" ) );
133+
assertThat( e.getMessage(), startsWith( "Transaction cannot be committed" ) );
134134
}
135135

136136
@Test
@@ -152,7 +152,7 @@ void shouldFailToRollbackAfterCommit()
152152
assertNull( await( tx.commitAsync() ) );
153153

154154
ClientException e = assertThrows( ClientException.class, () -> await( tx.rollbackAsync() ) );
155-
assertEquals( "Can't rollback, transaction has been committed", e.getMessage() );
155+
assertEquals( "Cannot rollback, transaction has been committed", e.getMessage() );
156156
assertFalse( tx.isOpen() );
157157
}
158158

@@ -186,7 +186,7 @@ void shouldBePossibleToRunMoreTransactionsAfterOneIsTerminated()
186186

187187
// commit should fail, make session forget about this transaction and release the connection to the pool
188188
ClientException e = assertThrows( ClientException.class, () -> await( tx1.commitAsync() ) );
189-
assertThat( e.getMessage(), startsWith( "Transaction can't be committed" ) );
189+
assertThat( e.getMessage(), startsWith( "Transaction cannot be committed" ) );
190190

191191
await( session.beginTransactionAsync( TransactionConfig.empty() )
192192
.thenCompose( tx -> tx.runAsync( new Statement( "CREATE (:Node {id: 42})" ), true )

driver/src/test/java/org/neo4j/driver/integration/SessionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ void writeTxFailWhenBothCommitAndRollback()
484484
return 42;
485485
} ) );
486486

487-
assertThat( error.getMessage(), startsWith( "Can't rollback, transaction has been committed" ) );
487+
assertThat( error.getMessage(), startsWith( "Cannot rollback, transaction has been committed" ) );
488488
}
489489
}
490490
}

driver/src/test/java/org/neo4j/driver/integration/TransactionIT.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void shouldFailToCommitAfterRolledBack()
147147
tx.rollback();
148148

149149
ClientException e = assertThrows( ClientException.class, tx::commit );
150-
assertThat( e.getMessage(), startsWith( "Can't commit, transaction has been rolled back" ) );
150+
assertThat( e.getMessage(), startsWith( "Cannot commit, transaction has been rolled back" ) );
151151
}
152152

153153
@Test
@@ -158,7 +158,7 @@ void shouldFailToRollbackAfterTxIsCommitted()
158158
tx.commit();
159159

160160
ClientException e = assertThrows( ClientException.class, tx::rollback );
161-
assertThat( e.getMessage(), startsWith( "Can't rollback, transaction has been committed" ) );
161+
assertThat( e.getMessage(), startsWith( "Cannot rollback, transaction has been committed" ) );
162162
}
163163

164164
@Test
@@ -169,7 +169,7 @@ void shouldFailToCommitAfterCommit() throws Throwable
169169
tx.commit();
170170

171171
ClientException e = assertThrows( ClientException.class, tx::commit );
172-
assertThat( e.getMessage(), startsWith( "Can't commit, transaction has been committed" ) );
172+
assertThat( e.getMessage(), startsWith( "Cannot commit, transaction has been committed" ) );
173173
}
174174

175175
@Test
@@ -180,7 +180,7 @@ void shouldFailToRollbackAfterRollback() throws Throwable
180180
tx.rollback();
181181

182182
ClientException e = assertThrows( ClientException.class, tx::rollback );
183-
assertThat( e.getMessage(), startsWith( "Can't rollback, transaction has been rolled back" ) );
183+
assertThat( e.getMessage(), startsWith( "Cannot rollback, transaction has been rolled back" ) );
184184
}
185185

186186

@@ -437,7 +437,7 @@ void shouldFailToCommitAfterFailure() throws Throwable
437437
assertThat( error1.code(), containsString( "SyntaxError" ) );
438438

439439
ClientException error2 = assertThrows( ClientException.class, tx::commit );
440-
assertThat( error2.getMessage(), startsWith( "Transaction can't be committed. It has been rolled back" ) );
440+
assertThat( error2.getMessage(), startsWith( "Transaction cannot be committed. It has been rolled back" ) );
441441
}
442442
}
443443

@@ -484,7 +484,7 @@ void shouldRollbackWhenMarkedSuccessfulButOneStatementFails()
484484
assertThat( error.getSuppressed().length, greaterThanOrEqualTo( 1 ) );
485485
Throwable suppressed = error.getSuppressed()[0];
486486
assertThat( suppressed, instanceOf( ClientException.class ) );
487-
assertThat( suppressed.getMessage(), startsWith( "Transaction can't be committed" ) );
487+
assertThat( suppressed.getMessage(), startsWith( "Transaction cannot be committed" ) );
488488

489489
assertEquals( 0, countNodesByLabel( "Node1" ) );
490490
assertEquals( 0, countNodesByLabel( "Node2" ) );

driver/src/test/java/org/neo4j/driver/integration/async/AsyncTransactionIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ void shouldFailToCommitWhenRunFailureIsConsumed()
777777
assertThat( e1.code(), containsString( "SyntaxError" ) );
778778

779779
ClientException e2 = assertThrows( ClientException.class, () -> await( tx.commitAsync() ) );
780-
assertThat( e2.getMessage(), startsWith( "Transaction can't be committed" ) );
780+
assertThat( e2.getMessage(), startsWith( "Transaction cannot be committed" ) );
781781
}
782782

783783
@Test
@@ -791,7 +791,7 @@ void shouldFailToCommitWhenPullAllFailureIsConsumed()
791791
assertThat( e1.code(), containsString( "TypeError" ) );
792792

793793
ClientException e2 = assertThrows( ClientException.class, () -> await( tx.commitAsync() ) );
794-
assertThat( e2.getMessage(), startsWith( "Transaction can't be committed" ) );
794+
assertThat( e2.getMessage(), startsWith( "Transaction cannot be committed" ) );
795795
}
796796

797797
@Test

driver/src/test/java/org/neo4j/driver/integration/reactive/RxTransactionIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void shouldFailToCommitWhenCommitted()
266266
// second commit should wrap around a completed future
267267
StepVerifier.create( secondCommit ).expectErrorSatisfies( error -> {
268268
assertThat( error, instanceOf( ClientException.class ) );
269-
assertThat( error.getMessage(), startsWith( "Can't commit, transaction has been committed" ) );
269+
assertThat( error.getMessage(), startsWith( "Cannot commit, transaction has been committed" ) );
270270
} ).verify();
271271

272272
}
@@ -282,7 +282,7 @@ void shouldFailToRollbackWhenRolledBack()
282282
// second rollback should wrap around a completed future
283283
StepVerifier.create( secondRollback ).expectErrorSatisfies( error -> {
284284
assertThat( error, instanceOf( ClientException.class ) );
285-
assertThat( error.getMessage(), startsWith( "Can't rollback, transaction has been rolled back" ) );
285+
assertThat( error.getMessage(), startsWith( "Cannot rollback, transaction has been rolled back" ) );
286286
} ).verify();
287287
}
288288

0 commit comments

Comments
 (0)