aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/application_controller.erl
diff options
context:
space:
mode:
authorAndy Ledvina <[email protected]>2014-10-21 23:38:57 -0700
committerAndy Ledvina <[email protected]>2015-02-16 09:12:18 -0800
commit7a8b845f6ff3e0646a9ca35352eda23cfa4dd656 (patch)
tree6e7e02c932247bec2bab4f7a9632d7faccdc8caf /lib/kernel/src/application_controller.erl
parentef8b1e3e8c908379cec8376ed515c920682224f9 (diff)
downloadotp-7a8b845f6ff3e0646a9ca35352eda23cfa4dd656.tar.gz
otp-7a8b845f6ff3e0646a9ca35352eda23cfa4dd656.tar.bz2
otp-7a8b845f6ff3e0646a9ca35352eda23cfa4dd656.zip
Add helper function to reduce code duplication
I was going through application_controller.erl looking for why something was behaving a certain way, saw a comment about removing this duplicated code one day, and decided to move that a step forward.
Diffstat (limited to 'lib/kernel/src/application_controller.erl')
-rw-r--r--lib/kernel/src/application_controller.erl14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/kernel/src/application_controller.erl b/lib/kernel/src/application_controller.erl
index daad45b6c2..6635885aaf 100644
--- a/lib/kernel/src/application_controller.erl
+++ b/lib/kernel/src/application_controller.erl
@@ -1615,7 +1615,6 @@ conv([Key, Val | T]) ->
[{make_term(Key), make_term(Val)} | conv(T)];
conv(_) -> [].
-%%% Fix some day: eliminate the duplicated code here
make_term(Str) ->
case erl_scan:string(Str) of
{ok, Tokens, _} ->
@@ -1623,16 +1622,17 @@ make_term(Str) ->
{ok, Term} ->
Term;
{error, {_,M,Reason}} ->
- error_logger:format("application_controller: ~ts: ~ts~n",
- [M:format_error(Reason), Str]),
- throw({error, {bad_environment_value, Str}})
+ handle_make_term_error(M, Reason, Str)
end;
{error, {_,M,Reason}, _} ->
- error_logger:format("application_controller: ~ts: ~ts~n",
- [M:format_error(Reason), Str]),
- throw({error, {bad_environment_value, Str}})
+ handle_make_term_error(M, Reason, Str)
end.
+handle_make_term_error(Mod, Reason, Str) ->
+ error_logger:format("application_controller: ~ts: ~ts~n",
+ [Mod:format_error(Reason), Str]),
+ throw({error, {bad_environment_value, Str}}).
+
get_env_i(Name, #state{conf_data = ConfData}) when is_list(ConfData) ->
case lists:keyfind(Name, 1, ConfData) of
{_Name, Env} -> Env;