Skip to content

Commit

Permalink
Merge pull request #384 from evaline-ju/err-details
Browse files Browse the repository at this point in the history
🥅 Handle error details on inactive rpc errors
  • Loading branch information
gkumbhat authored Aug 19, 2024
2 parents d7cca1a + 723ade9 commit a55b72e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions caikit_nlp/toolkit/text_generation/tgis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,16 @@ 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
raise CaikitCoreException(caikit_status_code, details) from err
except grpc.RpcError as err:
raise_caikit_core_exception(err)

Expand Down Expand Up @@ -663,13 +666,16 @@ 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
raise CaikitCoreException(caikit_status_code, details) from err
except grpc.RpcError as err:
raise_caikit_core_exception(err)

Expand Down

0 comments on commit a55b72e

Please sign in to comment.