better error handling of invalid enum conversion