From 51bbd74a27d49cb5f6f3a228e5168418a5f17215 Mon Sep 17 00:00:00 2001 From: "Heather MacDonald (she/her)" <80712961+hmacdonald-verta@users.noreply.github.com> Date: Mon, 22 Mar 2021 13:34:24 -0700 Subject: [PATCH] Modify error logging methods so they work with grpc future-wrappers in registry (#2044) --- .../main/java/ai/verta/modeldb/common/CommonUtils.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/common/src/main/java/ai/verta/modeldb/common/CommonUtils.java b/backend/common/src/main/java/ai/verta/modeldb/common/CommonUtils.java index 3476758acf..ab68ee95f1 100644 --- a/backend/common/src/main/java/ai/verta/modeldb/common/CommonUtils.java +++ b/backend/common/src/main/java/ai/verta/modeldb/common/CommonUtils.java @@ -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 StatusRuntimeException logError( - Exception e, T defaultInstance) { + Throwable e, T defaultInstance) { Status status; StatusRuntimeException statusRuntimeException; if (e instanceof StatusRuntimeException) { @@ -178,6 +178,11 @@ public static StatusRuntimeException logError( return statusRuntimeException; } + public static void observeError( + StreamObserver responseObserver, Throwable e) { + responseObserver.onError(logError(e)); + } + public static void observeError( StreamObserver responseObserver, Exception e, T defaultInstance) { responseObserver.onError(logError(e, defaultInstance));