Skip to content

Populate handler exception message #1875

Open
@hgong-snap

Description

@hgong-snap

🚀 The feature

Populate exception message

Motivation, pitch

Currently, if the handler raise some random error, the client will receives only InternalServerException without error/exception details

<_InactiveRpcError of RPC that terminated with:
	status = StatusCode.UNAVAILABLE
	details = "Prediction failed
org.pytorch.serve.http.InternalServerException"
	debug_error_string = "UNKNOWN:Error received from peer ipv6:%5B::1%5D:17100 {created_time:"2022-09-26T15:40:29.722145-07:00", grpc_status:14, grpc_message:"Prediction failed\norg.pytorch.serve.http.InternalServerException"}"
>

what I do now is basically add a wrapper everywhere:

from ts.utils.util import PredictionException

# in handler
try:
  self.do_something_and_raise_exception()  # this will raise some random Exception
except Exception as e:
  raise PredictionException(str(e), 503)

This way exception message from original exception will be populated in GRPC:

<_InactiveRpcError of RPC that terminated with:
	status = StatusCode.UNAVAILABLE
	details = "Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
org.pytorch.serve.http.InternalServerException"

Is this expected? is it possible to have this kinda wrapper everywhere?

Alternatives

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions