diff --git a/caikit_nlp/toolkit/text_generation/tgis_utils.py b/caikit_nlp/toolkit/text_generation/tgis_utils.py index 675877d8..724773ed 100644 --- a/caikit_nlp/toolkit/text_generation/tgis_utils.py +++ b/caikit_nlp/toolkit/text_generation/tgis_utils.py @@ -476,13 +476,17 @@ def unary_generate( request, timeout=self.tgis_req_timeout ) except grpc._channel._InactiveRpcError as err: - log.error("", err.details()) + details = err.details() + log.error("", details) caikit_status_code = GRPC_TO_CAIKIT_CORE_STATUS.get( err.code(), CaikitCoreStatusCode.UNKNOWN ) - raise CaikitCoreException( - caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE - ) from err + if caikit_status_code == CaikitCoreStatusCode.CONNECTION_ERROR: + raise CaikitCoreException( + caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE + ) from err + else: + raise CaikitCoreException(caikit_status_code, details) from err except grpc.RpcError as err: raise_caikit_core_exception(err) @@ -663,13 +667,17 @@ def stream_generate( details=details, ) except grpc._channel._InactiveRpcError as err: - log.error("", err.details()) + details = err.details() + log.error("", details) caikit_status_code = GRPC_TO_CAIKIT_CORE_STATUS.get( err.code(), CaikitCoreStatusCode.UNKNOWN ) - raise CaikitCoreException( - caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE - ) from err + if caikit_status_code == CaikitCoreStatusCode.CONNECTION_ERROR: + raise CaikitCoreException( + caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE + ) from err + else: + raise CaikitCoreException(caikit_status_code, details) from err except grpc.RpcError as err: raise_caikit_core_exception(err)