Skip to content

Commit fe5123c

Browse files
committed
Properly handle TestKit's FrontendError
1 parent a68f5b8 commit fe5123c

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package neo4j.org.testkit.backend;
20+
21+
public class FrontendError extends RuntimeException
22+
{
23+
}

testkit-backend/src/main/java/neo4j/org/testkit/backend/channel/handler/TestkitRequestProcessorHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.netty.channel.ChannelHandlerContext;
2323
import io.netty.channel.ChannelInboundHandlerAdapter;
2424
import neo4j.org.testkit.backend.CustomDriverError;
25+
import neo4j.org.testkit.backend.FrontendError;
2526
import neo4j.org.testkit.backend.TestkitState;
2627
import neo4j.org.testkit.backend.messages.requests.TestkitRequest;
2728
import neo4j.org.testkit.backend.messages.responses.BackendError;
@@ -160,6 +161,10 @@ else if ( throwable instanceof CustomDriverError )
160161
)
161162
.build();
162163
}
164+
else if ( throwable instanceof FrontendError )
165+
{
166+
return neo4j.org.testkit.backend.messages.responses.FrontendError.builder().build();
167+
}
163168
else
164169
{
165170
return BackendError.builder().data( BackendError.BackendErrorBody.builder().msg( throwable.toString() ).build() ).build();

testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/RetryableNegative.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import lombok.Getter;
2222
import lombok.Setter;
23+
import neo4j.org.testkit.backend.FrontendError;
2324
import neo4j.org.testkit.backend.TestkitState;
2425
import neo4j.org.testkit.backend.holder.SessionHolder;
2526
import neo4j.org.testkit.backend.messages.responses.TestkitResponse;
@@ -44,7 +45,7 @@ public TestkitResponse process( TestkitState testkitState )
4445
}
4546
else
4647
{
47-
throwable = new RuntimeException( "Error from client in retryable tx" );
48+
throwable = new FrontendError();
4849
}
4950
sessionHolder.getTxWorkFuture().completeExceptionally( throwable );
5051
return null;
@@ -64,7 +65,7 @@ public CompletionStage<TestkitResponse> processAsync( TestkitState testkitState
6465
}
6566
else
6667
{
67-
throwable = new RuntimeException( "Error from client in retryable tx" );
68+
throwable = new FrontendError();
6869
}
6970
sessionHolder.getTxWorkFuture().completeExceptionally( throwable );
7071
return null;
@@ -85,7 +86,7 @@ public Mono<TestkitResponse> processRx( TestkitState testkitState )
8586
}
8687
else
8788
{
88-
throwable = new RuntimeException( "Error from client in retryable tx" );
89+
throwable = new FrontendError();
8990
}
9091
sessionHolder.getTxWorkFuture().completeExceptionally( throwable );
9192
return null;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package neo4j.org.testkit.backend.messages.responses;
20+
21+
import lombok.Builder;
22+
import lombok.Getter;
23+
24+
@Getter
25+
@Builder
26+
public class FrontendError implements TestkitResponse
27+
{
28+
private final FrontendErrorBody data = new FrontendErrorBody("Imagine client code that throws...");
29+
30+
@Override
31+
public String testkitName()
32+
{
33+
return "FrontendError";
34+
}
35+
36+
@Getter
37+
@Builder
38+
public static class FrontendErrorBody
39+
{
40+
private String msg;
41+
}
42+
}

0 commit comments

Comments
 (0)