Maybe you can use String.to_existing_atom/1 and handle ArgumentError accordingly
String.to_existing_atom/1
ArgumentError