Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
Added a check for an empty config to 'nakaz_utils'
Browse files Browse the repository at this point in the history
  • Loading branch information
superbobry committed Jul 8, 2012
1 parent 2ea8422 commit 2a6fcf0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/nakaz_errors.erl
Expand Up @@ -15,6 +15,8 @@ r({cant_execute_magic_fun, Mod}) ->
%% FIXME(Dmitry): rename parsetransform to nakaz_pt
{"Can't execute 'magic function' that must be generated "
"by nakaz_pt in module ~s", [Mod]};
r(empty) ->
{"Ooops, looks like the config is empty", []};
r({malformed, [{app, {Name, _Body}}|_Rest]}) ->
{"Malformed application structure in ~p, sections aren't mappings?",
[Name]};
Expand Down
4 changes: 2 additions & 2 deletions src/nakaz_internal.hrl
Expand Up @@ -58,8 +58,8 @@
-type untypical_readfile_errors() :: badarg
| terminated.

-type config_structure_error() :: {malformed, [{section, atom()} |
{app, atom()}]}.
-type config_structure_error() :: empty
| {malformed, [{section | app, atom()}]}.

-type proplist() :: [{any(), any()}].
-type proplist(K, V) :: [{K, V}].
2 changes: 2 additions & 0 deletions src/nakaz_utils.erl
Expand Up @@ -5,6 +5,8 @@
%% FIXME(Dmitry): spec
-spec check_config_structure(raw_config()) -> {ok, raw_config()}
| {error, config_structure_error()}.
check_config_structure([]) ->
{error, empty};
check_config_structure([{RawConfig, _pos}]) ->
case check_config_apps(RawConfig) of
[] -> {ok, RawConfig};
Expand Down

0 comments on commit 2a6fcf0

Please sign in to comment.