-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Labels
kind/enhancementSomething could be better.Something could be better.status/acceptedWe were able to reproduce the issue and accept to work on it.We were able to reproduce the issue and accept to work on it.
Description
It would be helpful to have a more Exception classes to make it easier to handle several common error cases. Currently, grpc.StatusCode.ABORTED is raised as AbortedError, but only by Txn.mutate() and Txn.commit(). To handle an aborted transaction for DgraphClient.alter(), the following is still required:
try:
client.alter(...)
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.ABORTED:
# handle
else:
raise
Other errors may not even have a StatusCode, and require something like this:
try:
client.alter(...)
except grpc.RpcError as e:
if e.code() == grpc.StatusCode.UNKNOWN:
if e.details().startswith('Pending transactions found'):
# handle
else:
raise
else:
raise
I frequently see StatusCode.ABORTED, StatusCode.UNKNOWN (in my case, pending transactions), and StatusCode.DEADLINE_EXCEEDED (timeouts). Each of these can be resolved by retrying the operation, so it's necessary to distinguish them from other error cases. It would be helpful if these could be caught as follows:
try:
client.alter(...)
except pydgraph.errors.PendingTransactionError:
# handle
Metadata
Metadata
Assignees
Labels
kind/enhancementSomething could be better.Something could be better.status/acceptedWe were able to reproduce the issue and accept to work on it.We were able to reproduce the issue and accept to work on it.