Elixir: Add `System` function that raises if ENV var is not present

Created on 3 Jan 2017  路  2Comments  路  Source: elixir-lang/elixir

Continuing from this forum discussion: https://groups.google.com/forum/#!msg/elixir-lang-core/yw54VGwGkt4/GGoh7ZEmFAAJ

The current method of getting ENV variables is System.get_env, but this returns nil if the variable is missing. This can lead to confusing errors if not explicitly handled, so it would be nice to have fetch_env and fetch_env! functions that would return an error tuple or raise on missing variables. This will fail fast and make it easier to debug.

Elixir Feature Starter

Most helpful comment

Was also looking for this but noticed the posted rationale link just goes to this page. I assume @josevalim meant to post the PR where it was discussed, you can find that here: https://github.com/elixir-lang/elixir/pull/5610#issuecomment-270127996

All 2 comments

Please see rationale for closing this on #5608.

Was also looking for this but noticed the posted rationale link just goes to this page. I assume @josevalim meant to post the PR where it was discussed, you can find that here: https://github.com/elixir-lang/elixir/pull/5610#issuecomment-270127996

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jdeisenberg picture jdeisenberg  路  4Comments

josevalim picture josevalim  路  3Comments

lukaszsamson picture lukaszsamson  路  3Comments

andrewcottage picture andrewcottage  路  3Comments

shadowfacts picture shadowfacts  路  3Comments