couple of failure modes for enums

Strings that don't define a valid name for the enumeration automatically
cause an error already. Now, integers are checked against valid values
and an exception is thrown if the integer is out of range.