Skip to content

Commit

Permalink
Modify error logging methods so they work with grpc future-wrappers i…
Browse files Browse the repository at this point in the history
…n registry (#2044)
  • Loading branch information
Heather MacDonald (she/her) committed Mar 22, 2021
1 parent 25a0580 commit 51bbd74
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ public static Object retryOrThrowException(
throw ex;
}

public static StatusRuntimeException logError(Exception e) {
public static StatusRuntimeException logError(Throwable e) {
return logError(e, null);
}

public static <T extends GeneratedMessageV3> StatusRuntimeException logError(
Exception e, T defaultInstance) {
Throwable e, T defaultInstance) {
Status status;
StatusRuntimeException statusRuntimeException;
if (e instanceof StatusRuntimeException) {
Expand Down Expand Up @@ -178,6 +178,11 @@ public static <T extends GeneratedMessageV3> StatusRuntimeException logError(
return statusRuntimeException;
}

public static <T extends GeneratedMessageV3> void observeError(
StreamObserver<T> responseObserver, Throwable e) {
responseObserver.onError(logError(e));
}

public static <T extends GeneratedMessageV3> void observeError(
StreamObserver<T> responseObserver, Exception e, T defaultInstance) {
responseObserver.onError(logError(e, defaultInstance));
Expand Down

0 comments on commit 51bbd74

Please sign in to comment.