Skip to content

Is it possible to extract extended gRPC details from Python exception? #22

@rdmoore

Description

@rdmoore

I am trying to extract the "details" portion of a gRPC error using Python as the client language. The core protobuf definition that I am basing the behavior on is documented here. Example client code block:

    try:
       response = client.Create(req, timeout=30)
       print(response)
    except grpc._channel._InactiveRpcError as e:
           print("caught as inactive RPC error")
           print(e.__class__)
           print(e.details.__class__)
           print(e.details)

I was expected the details to be the extended content rather than the error message. Am I overlooking something obvious? Is this not supported in the Python client library?

The server-side code is written in go and looks something like this:

		s := status.New(codes.AlreadyExists, "dataset already exists for combination of subject and provenance")
		if s, err = s.WithDetails(res.VersionSets[0]); err != nil {
			logrus.Panicf("cannot add details to google.rpc.Status: %+v", err)
		}
		return nil, s.Err()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions