def add_bgp_error_metadata(code, sub_code, def_desc='unknown'):
 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.\n\n        If given class is sub-class of BGPSException we sets class constants.\n        '
  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

def add_bgp_error_metadata ( code , sub_code , def_desc = 'unknown' ) : 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 ) : 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
decorator for all exceptions that want to set exception class meta-data .