Skip to content

Commit

Permalink
🔧 Move err message to const as per review suggestion
Browse files Browse the repository at this point in the history
Signed-off-by: gkumbhat <kumbhat.gaurav@gmail.com>
  • Loading branch information
gkumbhat committed Aug 2, 2024
1 parent 226d7b8 commit d6adb79
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions caikit_nlp/toolkit/text_generation/tgis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
# HTTP Header / gRPC Metadata key used to identify a route override
# (forwarded for API compatibility)
ROUTE_INFO_HEADER_KEY = TGISBackend.ROUTE_INFO_HEADER_KEY
INACTIVE_RPC_CONN_ERR_MESSAGE = "The underlying TCP connection is closed"
get_route_info = TGISBackend.get_route_info


Expand Down Expand Up @@ -476,11 +477,12 @@ def unary_generate(
)
except grpc._channel._InactiveRpcError as err:
log.error("<NLP30829218E>", err.details)
error_message = "The underlying TCP connection is closed"
caikit_status_code = GRPC_TO_CAIKIT_CORE_STATUS.get(
err.code(), CaikitCoreStatusCode.UNKNOWN
)
raise CaikitCoreException(caikit_status_code, error_message) from err
raise CaikitCoreException(
caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE
) from err
except grpc.RpcError as err:
raise_caikit_core_exception(err)

Expand Down Expand Up @@ -662,11 +664,12 @@ def stream_generate(
)
except grpc._channel._InactiveRpcError as err:
log.error("<NLP11829118E>", err.details)
error_message = "The underlying TCP connection is closed"
caikit_status_code = GRPC_TO_CAIKIT_CORE_STATUS.get(
err.code(), CaikitCoreStatusCode.UNKNOWN
)
raise CaikitCoreException(caikit_status_code, error_message) from err
raise CaikitCoreException(
caikit_status_code, INACTIVE_RPC_CONN_ERR_MESSAGE
) from err
except grpc.RpcError as err:
raise_caikit_core_exception(err)

Expand Down

0 comments on commit d6adb79

Please sign in to comment.