def add_error_class(klass, code):
 if (not isinstance(code, python.str_types)):
  code = code.decode('utf-8')
 if (not isinstance(klass, python.class_types)):
  raise TypeError('klass must be a class type')
 mro = inspect.getmro(klass)
 if (not (Exception in mro)):
  raise TypeError('Error classes must subclass the __builtin__.Exception class')
 if (code in ERROR_CLASS_MAP):
  raise ValueError(('Code %s is already registered' % (code,)))
 ERROR_CLASS_MAP[code] = klass

def add_error_class ( klass , code ) : if ( not isinstance ( code , python . str_types ) ) : code = code . decode ( 'utf-8' ) if ( not isinstance ( klass , python . class_types ) ) : raise TypeError ( 'klass must be a class type' ) mro = inspect . getmro ( klass ) if ( not ( Exception in mro ) ) : raise TypeError ( 'Error classes must subclass the __builtin__.Exception class' ) if ( code in ERROR_CLASS_MAP ) : raise ValueError ( ( 'Code %s is already registered' % ( code , ) ) ) ERROR_CLASS_MAP [ code ] = klass
maps an exception class to a string code .