I'm working on it, PR will be up in a few minutes. Andrea Leopardi [email protected]
On Fri, Mar 1, 2019 at 10:00 AM José Valim <[email protected]> wrote: > I agree. But it should be called System.fetch_env!/2 and we should have > System.fetch_env/2 too. PR is welcome. > > > *José Valim* > www.plataformatec.com.br > Skype: jv.ptec > Founder and Director of R&D > > > On Fri, Mar 1, 2019 at 9:38 AM <[email protected]> wrote: > >> I really would to see something like this on elixir. I suggested >> something really similar, the addition of an `fetch_env!` function to the >> System module. >> https://groups.google.com/forum/#!msg/elixir-lang-core/gijvoPm-a-0/Y2TzcHaiBgAJ >> >> >> Em sexta-feira, 1 de março de 2019 14:03:03 UTC-3, Fl4m3Ph03n1x escreveu: >>> >>> Background >>> I know this was proposed before and refuted: >>> https://github.com/elixir-lang/elixir/issues/5608 >>> >>> However, I recently had an issue that would have benefited from >>> System.get_env! and was advised to create a proposal in this group and >>> reopen the discussion. >>> >>> What was the issue? >>> Imagine you have a config.exs where you define some configurations. >>> Imagine one of the configurations is the following: >>> >>> config :my_app, >>> geolix_db_path: System.get_env("PROJECTS_PATH") <> >>> "/my_app/lib/geoip/GeoLite2-Country.mmdb" >>> >>> Now this may look normal, but what if you don't have the "PROJETCS_PATH" >>> variable defined? >>> What error do you think you would get? >>> >>> We got this: >>> >>> ** (ArgumentError) argument error >>> (stdlib) eval_bits.erl:101: :eval_bits.eval_exp_field1/6 >>> (stdlib) eval_bits.erl:92: :eval_bits.eval_field/3 >>> (stdlib) eval_bits.erl:68: :eval_bits.expr_grp/4 >>> (stdlib) erl_eval.erl:484: :erl_eval.expr/5 >>> (stdlib) erl_eval.erl:888: :erl_eval.expr_list/6 >>> (stdlib) erl_eval.erl:240: :erl_eval.expr/5 >>> (stdlib) erl_eval.erl:232: :erl_eval.expr/5 >>> >>> What now? >>> If you find this error message borderline useless and beyond cryptic, then >>> you are with me. >>> The problem is that the stacktrace is obfuscated while the config file is >>> being evaluated. >>> >>> The WHY of the proposal >>> A way of avoiding this would be to have a System.get_env! that blows >>> immediately making the error very clear. >>> I know I can use || raise "error" but I would like to avoid that every time >>> I use System.get_env in a config file (or somewhere else for that matter). >>> >>> Have you imagined what is like reading a config.ex file hundreds of lines >>> long while using the || raise trick? >>> We already have trouble managing our huge config files, adding this would >>> make it even worst. >>> >>> Additional info >>> This discussion was generated from the forums. The original post with all >>> the information can be seen here: >>> >>> https://elixirforum.com/t/mix-exs-does-not-compile/20516 >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/9b535dab-41b5-4caf-a7fc-b9e918aeffa0%40googlegroups.com >> <https://groups.google.com/d/msgid/elixir-lang-core/9b535dab-41b5-4caf-a7fc-b9e918aeffa0%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4J7xZsKNGPo6qgLcbohbP9oMM89D_zWobKwgQ%3DFPYVvHA%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4J7xZsKNGPo6qgLcbohbP9oMM89D_zWobKwgQ%3DFPYVvHA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BLVjca5WJiAevYhAyKDOGZRJ4H%2BTAfHe8MzUxGw29k4SA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
