def __call__(self, servicer, request, context): try: return self.handler(servicer, request, context) except exceptions.RpcException as e: context.set_code(e.code) context.set_details(e.details) return default_pb2.Empty()
def __call__(self, servicer, request, context): try: return self.handler(servicer, request, context) except Exception as e: self.app.logger.exception(str(e), exc_info=True) context.set_code(grpc.StatusCode.INTERNAL) context.set_details('Internal Error Occured') return default_pb2.Empty()
def __call__(self, servicer, request, context): request, context = self.before_handler(servicer, request, context) response = self.handler(servicer, request, context) if response is None: context.set_code(grpc.StatusCode.UNAUTHENTICATED) context.set_details('JWT AUTH FAILED!') return default_pb2.Empty() return self.after_handler(servicer, response)
def __call__(self, servicer, request, context): try: return self.handler(servicer, request, context) except (ModelNotFound, RelatedClassNotFound) as e: context.set_code(grpc.StatusCode.NOT_FOUND) context.set_details(str(e)) except ValidationError as e: context.set_code(grpc.StatusCode.INVALID_ARGUMENT) context.set_details(str(e)) return default_pb2.Empty()
def __call__(self, servicer, request, context): try: self.connect_db() return self.handler(servicer, request, context) except DoesNotExist as e: context.set_code(grpc.StatusCode.NOT_FOUND) context.set_details('Record Not Found') except ValidationError as e: context.set_code(grpc.StatusCode.INVALID_ARGUMENT) context.set_details(str(e)) finally: self.close_db() return default_pb2.Empty()