Skip to content

Commit

Permalink
🥅 Handle non-connection errors
Browse files Browse the repository at this point in the history
Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com>
  • Loading branch information
evaline-ju committed Aug 16, 2024
1 parent aea6ece commit 24fbc92
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions caikit_nlp/toolkit/text_generation/tgis_utils.py
Original file line number Diff line number Diff line change
@@ -476,13 +476,17 @@ def unary_generate(
request, timeout=self.tgis_req_timeout
)
except grpc._channel._InactiveRpcError as err:
log.error("<NLP30829218E>", err.details())
details = err.details()
log.error("<NLP30829218E>", 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("<NLP11829118E>", err.details())
details = err.details()
log.error("<NLP11829118E>", 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)

0 comments on commit 24fbc92

Please sign in to comment.