예제 #1
0
 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()
예제 #2
0
 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()
예제 #3
0
    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)
예제 #4
0
 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()
예제 #5
0
파일: sea.py 프로젝트: HeathLee/peeweext
 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()