Skip to content

Commit

Permalink
fix: complete the error code of ResultSet into QueryException.
Browse files Browse the repository at this point in the history
  • Loading branch information
CorvusYe authored Mar 16, 2024
2 parents 0e9f4df + 11b404b commit 324f8c3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ This source code is licensed under Apache 2.0 License.

# NEXT (1.2.2-SNAPSHOT)

## Bugfix

- fix: complete the error code of ResultSet into QueryException.

## Dependencies upgrade

- [ ] nebula-java: 3.6.0 -> 3.6.1
Expand Down
4 changes: 2 additions & 2 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ This source code is licensed under Apache 2.0 License.

NgBatis | nebula-java | JDK | Springboot | Beetl
---|-------------|---|------------|---
1.2.1-jdk17-SNAPSHOT | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.1-SNAPSHOT | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
1.2.2-jdk17-SNAPSHOT | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.2-SNAPSHOT | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE

> 在同版本号快照版中,依赖的第三方可能会随时升级
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ See [EXECUTION-PROCESS.md](./EXECUTION-PROCESS.md)

NgBatis | nebula-java | JDK | Springboot | Beetl
---|-------------|---|------------|---
1.2.1-jdk17-SNAPSHOT | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.1-SNAPSHOT | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
1.2.2-jdk17-SNAPSHOT | 3.6.0 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.2-SNAPSHOT | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE

> The third-party dependencies may differ within the same snapshot version.
Expand Down
2 changes: 1 addition & 1 deletion ngbatis-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>org.nebula-contrib</groupId>
<artifactId>ngbatis</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>ngbatis</name>
<groupId>org.nebula-contrib</groupId>
<artifactId>ngbatis</artifactId>
<version>1.2.1</version>
<version>1.2.2-SNAPSHOT</version>

<description>
NgBatis is a database ORM framework base NebulaGraph + spring-boot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,25 @@
*/
public class QueryException extends RuntimeException {

/**
* Set by {@link com.vesoft.nebula.client.graph.data.ResultSet#getErrorCode()}
* <br>
* Will be null when the exception is not caused by nGQL
*/
private Integer code;

public QueryException() {
}

public QueryException(String o) {
super(o);
}

public QueryException(String o, Integer code) {
super(o);
this.code = code;
}

public QueryException(String o, Throwable e) {
super(o, e);
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/nebula/contrib/ngbatis/proxy/MapperProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ public static ResultSet executeWithParameter(ClassModel cm, MethodModel mm, Stri
if (result.isSucceeded()) {
return result;
} else {
throw new QueryException(" 数据查询失败" + result.getErrorMessage());
throw new QueryException(
" 数据查询失败" + result.getErrorMessage(),
result.getErrorCode()
);
}
} catch (Exception e) {
throw new QueryException("数据查询失败:" + e.getMessage(), e);
Expand Down Expand Up @@ -285,7 +288,10 @@ public static ResultSet executeBySessionPool(ClassModel cm, MethodModel mm, Stri
if (result.isSucceeded()) {
return result;
} else {
throw new QueryException(" ResultSet error: " + result.getErrorMessage());
throw new QueryException(
" ResultSet error: " + result.getErrorMessage(),
result.getErrorCode()
);
}
} catch (Exception e) {
throw new QueryException("execute failed: " + e.getMessage(), e);
Expand Down

0 comments on commit 324f8c3

Please sign in to comment.