Skip to content

Commit

Permalink
error handling in ets fs read file
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Aug 22, 2014
1 parent bd06d0b commit 83aec5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Binary file modified mad
Binary file not shown.
12 changes: 6 additions & 6 deletions src/mad_repl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ applist() ->
{ok,Binary} -> parse_applist(Binary);
{error,_} ->
case mad_repl:load_file(Name) of
<<>> -> mad_plan:main([]);
Plan -> parse_applist(Plan) end end.
{error,_} -> mad_plan:main([]);
{ok,Plan} -> parse_applist(Plan) end end.

wildcards(List) -> lists:concat([filelib:wildcard(X)||X<-List]).

Expand All @@ -29,8 +29,8 @@ load_config() ->
Config = wildcards(["sys.config"]),
Apps = case Config of
[] -> case mad_repl:load_file("sys.config") of
<<>> -> [];
Bin -> parse(binary_to_list(Bin)) end;
{error,_} -> [];
{ok,Bin} -> parse(binary_to_list(Bin)) end;
File ->
case file:consult(File) of
{error,_} -> [];
Expand Down Expand Up @@ -102,8 +102,8 @@ ets_created() ->
load_file(Name) ->
ets_created(),
case ets:lookup(filesystem,Name) of
[{Name,Bin}] -> Bin;
_ -> <<>> end.
[{Name,Bin}] -> {ok,Bin};
_ -> {error,etsfs} end.

load_config(A) when is_atom(A) -> load_config(atom_to_list(A));
load_config(A) when is_list(A) ->
Expand Down

0 comments on commit 83aec5b

Please sign in to comment.