MCPcopy Create free account
hub / github.com/dgraph-io/dgraph4j / translate

Method translate

src/main/java/io/dgraph/Exceptions.java:47–62  ·  view source on GitHub ↗

Translates a Throwable into a typed DgraphException. If the throwable is already a DgraphException, returns it as-is. If it is a StatusRuntimeException, maps it by status code. Otherwise wraps it in a generic DgraphException.

(Throwable t)

Source from the content-addressed store, hash-verified

45 * Otherwise wraps it in a generic DgraphException.
46 */
47 public static DgraphException translate(Throwable t) {
48 // Unwrap CompletionException to get at the real cause
49 if (t instanceof CompletionException && t.getCause() != null) {
50 return translate(t.getCause());
51 }
52
53 if (t instanceof DgraphException) {
54 return (DgraphException) t;
55 }
56
57 if (t instanceof StatusRuntimeException) {
58 return fromStatusRuntimeException((StatusRuntimeException) t);
59 }
60
61 return new DgraphException(t.getMessage(), t);
62 }
63
64 /**
65 * Maps a StatusRuntimeException to a typed DgraphException. Status codes are the primary

Callers 15

testDeadlineExceededMethod · 0.95
testUnavailableGoawayMethod · 0.95
testResourceExhaustedMethod · 0.95
testUnauthenticatedMethod · 0.95
testPermissionDeniedMethod · 0.95
testAbortedMethod · 0.95

Calls 2

getMessageMethod · 0.80

Tested by 15

testDeadlineExceededMethod · 0.76
testUnavailableGoawayMethod · 0.76
testResourceExhaustedMethod · 0.76
testUnauthenticatedMethod · 0.76
testPermissionDeniedMethod · 0.76
testAbortedMethod · 0.76