Beispiel #1
0
 def dispatch(self, *args, **kwds):
     try:
         return super(RPCDispatcher, self).dispatch(*args, **kwds)
     except designate.exceptions.Base as e:
         if e.expected:
             raise rpc_dispatcher.ExpectedException()
         raise
Beispiel #2
0
 def _dispatch(self, *args, **kwds):
     try:
         return super(RPCDispatcher, self)._dispatch(*args, **kwds)
     except Exception as e:
         if getattr(e, 'expected', False):
             raise rpc_dispatcher.ExpectedException()
         else:
             raise
Beispiel #3
0
 def _dispatch(self, *args, **kwds):
     # TODO(kiall): Remove when oslo.messaging 5 is the min in requirements
     try:
         return super(RPCDispatcher, self)._dispatch(*args, **kwds)
     except Exception as e:
         if getattr(e, 'expected', False):
             raise rpc_dispatcher.ExpectedException()
         else:
             raise
Beispiel #4
0
 def inner(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     # Take advantage of the fact that we can catch
     # multiple exception types using a tuple of
     # exception classes, with subclass detection
     # for free. Any exception that is not in or
     # derived from the args passed to us will be
     # ignored and thrown as normal.
     except exceptions:
         raise rpc_dispatcher.ExpectedException()
Beispiel #5
0
 def inner(*args, **kwargs):
     try:
         span_host = tomograph.getHost()
         ser_name = "%s[%s]" % (func.__module__, func.__name__)
         tomograph.start(ser_name, func.__name__, span_host, 0)
         ret = func(*args, **kwargs)
         tomograph.stop(func.__name__)
         return ret
     # Take advantage of the fact that we can catch
     # multiple exception types using a tuple of
     # exception classes, with subclass detection
     # for free. Any exception that is not in or
     # derived from the args passed to us will be
     # ignored and thrown as normal.
     except exceptions:
         tomograph.stop(func.__name__)
         raise rpc_dispatcher.ExpectedException()
Beispiel #6
0
        def exception_wrapper(self, *args, **kwargs):
            if not hasattr(EXPECTED_EXCEPTION, 'depth'):
                EXPECTED_EXCEPTION.depth = 0
            EXPECTED_EXCEPTION.depth += 1

            # We only want to wrap the first function wrapped.
            if EXPECTED_EXCEPTION.depth > 1:
                return f(self, *args, **kwargs)

            try:
                return f(self, *args, **kwargs)
            except designate.exceptions.DesignateException as e:
                if e.expected:
                    raise rpc_dispatcher.ExpectedException()
                raise
            finally:
                EXPECTED_EXCEPTION.depth = 0