Skip to content

Commit

Permalink
Update Application docs to make them more accurate.
Browse files Browse the repository at this point in the history
The docs claimed that `get_env`/`fetch_env`/`fetch_env!` return
a default value/return :error/raise an exception when passed an
application that is not loaded. However, this is not the observed
behavior:

iex(1)> Application.put_env :foo, :bar, :baz
:ok
iex(2)> Application.get_env :foo, :bar
:baz
  • Loading branch information
myronmarston committed Jun 20, 2015
1 parent 2ead47e commit 73ea36b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/elixir/lib/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ defmodule Application do
@doc """
Returns the value for `key` in `app`'s environment.
If the specified application is not loaded, or the configuration parameter
does not exist, the function returns the `default` value.
If the configuration parameter does not exist, the function returns the
`default` value.
"""
@spec get_env(app, key, value) :: value
def get_env(app, key, default \\ nil) do
Expand All @@ -134,8 +134,7 @@ defmodule Application do
@doc """
Returns the value for `key` in `app`'s environment in a tuple.
If the specified application is not loaded, or the configuration parameter
does not exist, the function returns `:error`.
If the configuration parameter does not exist, the function returns `:error`.
"""
@spec fetch_env(app, key) :: {:ok, value} | :error
def fetch_env(app, key) do
Expand All @@ -148,8 +147,7 @@ defmodule Application do
@doc """
Returns the value for `key` in `app`'s environment.
If the specified application is not loaded, or the configuration parameter
does not exist, raises `ArgumentError`.
If the configuration parameter does not exist, raises `ArgumentError`.
"""
@spec fetch_env!(app, key) :: value | no_return
def fetch_env!(app, key) do
Expand Down

0 comments on commit 73ea36b

Please sign in to comment.