code: def add_bgp_error_metadata(code, sub_code, def_desc='unknown'):
      
      # Check registry if we already have an exception with same code/sub-code
      if _EXCEPTION_REGISTRY.get((code, sub_code)) is not None:
          raise ValueError('BGPSException with code %d and sub-code %d '
                           'already defined.' % (code, sub_code))
  
      def decorator(subclass):
          """Sets class constants for exception code and sub-code.
  
          If given class is sub-class of BGPSException we sets class constants.
          """
          if issubclass(subclass, BGPSException):
              _EXCEPTION_REGISTRY[(code, sub_code)] = subclass
              subclass.CODE = code
              subclass.SUB_CODE = sub_code
              subclass.DEF_DESC = def_desc
          return subclass
      return decorator
docs: Decorator for all exceptions that want to set exception class meta-data.