Skip to content
Snippets Groups Projects
Commit 0bce537c authored by Georges Racinet's avatar Georges Racinet
Browse files

gRPC errors: failed_precondition

yet another error helper modelled on the existing ones
parent 6ef5de19
No related branches found
Tags 0.8.1
1 merge request!57Blob and Tree related service methods
......@@ -99,3 +99,17 @@
logger.log(log_level, message)
context.set_details(message)
return response_cls()
def failed_precondition(context, response_cls, message,
log_level=logging.INFO):
"""Return grpc FAILED_PRECONDITION code with message.
Similar to :func:`not_found`, except for the default ``log_level``,
which is ``INFO`` because it seems to be used for routine stuff, like
fetching data only if size is smaller than a given limit.
"""
context.set_code(StatusCode.FAILED_PRECONDITION)
logger.log(log_level, message)
context.set_details(message)
return response_cls()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment