Is there a cleaner way of "failing" when attemptin...
# announcements
v
Is there a cleaner way of "failing" when attempting to create an enum where the supplied value does not match any of the enum values, than catching the IllegalArgumentException?
Copy code
try {
	val metaData: PostMetaData = PostMetaData.valueOf(it.key)
	println("\t\t metaData -> $metaData -> ${it.value}")
	if(metaData.required && it.value.isEmpty()) {
		return PostGenError("Missing required field '${metaData.name}' in source file '${fileName}'",fileName,metaData.name)
	}
} catch (iae: IllegalArgumentException) {
	println("found ${it.key} instead")
}
If the key doesn't match any of the enum constants, I still want to handle it, just in a different way.