File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -133,14 +133,16 @@ defmodule Application do
133133 @ doc """
134134 Returns the value for `key` in `app`'s specification.
135135
136- See `spec/1` for the supporte keys. If the given
136+ See `spec/1` for the supported keys. If the given
137137 specification parameter does not exist, this function
138- will raise.
138+ will raise. Returns `nil` if the application is not loaded.
139139 """
140- @ spec spec ( app , key ) :: value
140+ @ spec spec ( app , key ) :: value | nil
141141 def spec ( app , key ) when key in @ application_keys do
142- { :ok , value } = :application . get_key ( app , key )
143- value
142+ case :application . get_key ( app , key ) do
143+ { :ok , value } -> value
144+ :undefined -> nil
145+ end
144146 end
145147
146148 @ doc """
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ defmodule ApplicationTest do
3838 test "application specification" do
3939 assert is_list Application . spec ( :elixir )
4040 assert Application . spec ( :unknown ) == nil
41+ assert Application . spec ( :unknown , :description ) == nil
4142
4243 assert Application . spec ( :elixir , :description ) == 'elixir'
4344 assert_raise FunctionClauseError , fn -> Application . spec ( :elixir , :unknown ) end
You can’t perform that action at this time.
0 commit comments