I’m currently using
Application.get_env/3 to get some configuration in my Phoenix router. However, I just realized that the key was set incorrectly and it’s been returning nil without me realizing.
Currently the code looks like this:
api_hostname = Application.get_env(:web_interface, :api_hostname)
Ideally there would be a
Application.get_env!/3 that would raise an error when the key is not set, but since there is not what would be the cleanest way to accomplish this goal?
Here are some IMO ugly ways:
api_hostname = case Application.get_env(:web_interface, :api_hostname) do nil -> raise "Variable not set" var -> var end