So I am having multiple occurrences of similar snippets in my code:
val optionValue = try {
Some(config.getString(key))
} catch {
case _: Missing => None
}
I want to somehow eliminate this duplicates from my code. I know that typesafe provides a way to give a fallback config file to provide default config values. However, in my case, I am not having any default values for some properties. They are optional properties.
What will be the most optimal way to refactor this code.