-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from alex268/add_exception_message
Add SQLState to exceptions
- Loading branch information
Showing
13 changed files
with
71 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
jdbc/src/main/java/tech/ydb/jdbc/exception/YdbConditionallyRetryableException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package tech.ydb.jdbc.exception; | ||
|
||
import tech.ydb.core.StatusCode; | ||
import tech.ydb.core.Status; | ||
|
||
// Treat this as non retryable exception by nature, i.e. need to handle in consciously | ||
public class YdbConditionallyRetryableException extends YdbNonRetryableException { | ||
private static final long serialVersionUID = 1135970796364528563L; | ||
private static final long serialVersionUID = -2371144941971339449L; | ||
|
||
public YdbConditionallyRetryableException(String message, StatusCode statusCode) { | ||
super(message, statusCode); | ||
YdbConditionallyRetryableException(String message, String sqlState, Status status) { | ||
super(message, sqlState, status); | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
jdbc/src/main/java/tech/ydb/jdbc/exception/YdbExecutionStatusException.java
This file was deleted.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
jdbc/src/main/java/tech/ydb/jdbc/exception/YdbNonRetryableException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package tech.ydb.jdbc.exception; | ||
|
||
import tech.ydb.core.StatusCode; | ||
import tech.ydb.core.Status; | ||
|
||
public class YdbNonRetryableException extends YdbExecutionStatusException { | ||
private static final long serialVersionUID = 1170815831963616837L; | ||
public class YdbNonRetryableException extends YdbStatusException { | ||
private static final long serialVersionUID = 687247673341671225L; | ||
|
||
public YdbNonRetryableException(String message, StatusCode statusCode) { | ||
super(message, statusCode); | ||
YdbNonRetryableException(String message, String sqlState, Status status) { | ||
super(message, sqlState, status); | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
jdbc/src/main/java/tech/ydb/jdbc/exception/YdbRetryableException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package tech.ydb.jdbc.exception; | ||
|
||
import tech.ydb.core.StatusCode; | ||
import tech.ydb.core.Status; | ||
|
||
public class YdbRetryableException extends YdbExecutionStatusException { | ||
private static final long serialVersionUID = 688604408491567864L; | ||
public class YdbRetryableException extends YdbStatusException { | ||
private static final long serialVersionUID = 2082287790625648960L; | ||
|
||
public YdbRetryableException(String message, StatusCode statusCode) { | ||
super(message, statusCode); | ||
YdbRetryableException(String message, String sqlState, Status status) { | ||
super(message, sqlState, status); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
jdbc/src/main/java/tech/ydb/jdbc/exception/YdbStatusException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package tech.ydb.jdbc.exception; | ||
|
||
import tech.ydb.core.Status; | ||
import tech.ydb.core.StatusCode; | ||
|
||
public class YdbStatusException extends YdbExecutionException { | ||
private static final long serialVersionUID = -8082086858749679589L; | ||
|
||
private final Status status; | ||
|
||
protected YdbStatusException(String message, String state, Status status) { | ||
super(message, state, status.getCode().getCode()); | ||
this.status = status; | ||
} | ||
|
||
public Status getStatus() { | ||
return status; | ||
} | ||
|
||
public static YdbStatusException newException(String message, Status status) { | ||
if (status.getCode().isRetryable(false)) { | ||
String sqlState = "Retryable[" + status.toString() + "]"; | ||
return new YdbRetryableException(message, sqlState, status); | ||
} | ||
|
||
if (status.getCode().isRetryable(true)) { | ||
String sqlState = "ConditionallyRetryable[" + status.toString() + "]"; | ||
return new YdbConditionallyRetryableException(message, sqlState, status); | ||
} | ||
|
||
String sqlState = "NonRetryable[" + status.toString() + "]"; | ||
return new YdbNonRetryableException(message, sqlState, status); | ||
} | ||
|
||
public static YdbStatusException newBadRequest(String message) { | ||
Status status = Status.of(StatusCode.BAD_REQUEST); | ||
String sqlState = "NonRetryable[" + status.toString() + "]"; | ||
return new YdbNonRetryableException(message, sqlState, status); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters