On 29 June 2013 06:30, Ethan Furman <et...@stoneleaf.us> wrote: >> I would also not be shocked if some people expect failed value >> lookups to raise an IndexError, though I expect they would >> adapt if they get something else that makes sense. >> >> Would it be wrong to create an EnumError that subclasses >> (ValueError, KeyError, AttributeError) and to raise that >> subclass from everything but _StealthProperty and _get_mixins? > > > Wouldn't bother me; I'm not sure what the bar is for adding new exceptions, > though.
I'd actually do something a bit more complex, but also cleaner from a type system perspective: class EnumError(Exception): pass class EnumValueError(EnumError, ValueError): pass class EnumAttributeError(EnumError, AttributeError): pass class EnumKeyError(EnumError, KeyError): pass However, it's probably not necessary. The value lookup API should just document clearly which exception it throws. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com