Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Ensure all config get's throw on no ets table
  • Loading branch information
chewbranca committed Dec 4, 2023
commit 1e51ffbabf05356fcd26cfc5c8d19207b09de0b7
9 changes: 6 additions & 3 deletions src/config/src/config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ all() ->
lists:sort(gen_server:call(?MODULE, all, infinity)).

get_integer(Section, Key, Default) when is_integer(Default) ->
Val = get(Section, Key, Default),
try
to_integer(get(Section, Key, Default))
to_integer(Val)
catch
error:badarg ->
Default
Expand All @@ -91,8 +92,9 @@ to_integer(Bin) when is_binary(Bin) ->
list_to_integer(binary_to_list(Bin)).

get_float(Section, Key, Default) when is_float(Default) ->
Val = get(Section, Key, Default),
try
to_float(get(Section, Key, Default))
to_float(Val)
catch
error:badarg ->
Default
Expand All @@ -116,8 +118,9 @@ to_float(Bin) when is_binary(Bin) ->
list_to_float(binary_to_list(Bin)).

get_boolean(Section, Key, Default) when is_boolean(Default) ->
Val = get(Section, Key, Default),
try
to_boolean(get(Section, Key, Default))
to_boolean(Val)
catch
error:badarg ->
Default
Expand Down