CliMA / ClimaOcean.jl

🌎 Tools for realistic regional-to-global ocean simulations, and coupled ocean + sea-ice simulations based on Oceananigans and ClimaSeaIce. Basis for the ocean and sea-ice component of CliMA's Earth system model.
https://clima.github.io/ClimaOceanDocumentation/dev/
MIT License
26 stars 7 forks source link

Should we classify a missing environment variable as `ArgumentError`? #110

Open glwagner opened 1 month ago

glwagner commented 1 month ago

I'm not sure it's useful to call it ArgumentError:

https://github.com/CliMA/ClimaOcean.jl/blob/514135fc9a1016ec0c32081fe3914e789b3d35ca/src/DataWrangling/ecco_metadata.jl#L156

Maybe there is another error we can use.

The same applies to

https://github.com/CliMA/ClimaOcean.jl/blob/514135fc9a1016ec0c32081fe3914e789b3d35ca/src/DataWrangling/ecco_metadata.jl#L157

simone-silvestri commented 1 month ago

Maybe just

throw("Could not find the username for $(url). Please provide a password in the ECCO_PASSWORD environment variable.") 

would do the trick

glwagner commented 1 month ago

I think that would work. Another possibility is KeyError

https://docs.julialang.org/en/v1/base/base/#Base.KeyError

if you want to change the message to make it clear that ENV["ECCO_PASSWORD"] must exist. This can be achieved either by adding it to ENV or by setting the environment variable before starting julia (eg there is more than one way to achieve this).

glwagner commented 1 month ago

Btw there is a discussion about this here: https://discourse.julialang.org/t/how-to-best-store-and-access-credentials-in-julia/54997