Permalink
Browse files

present a more reasonable error message on startup failure

  • Loading branch information...
1 parent aa7aa36 commit dd5c2f4a6afa3673f024290b43bb93b36019b6fb @ericbmerritt committed Apr 30, 2012
Showing with 47 additions and 38 deletions.
  1. +47 −38 src/sinan.erl
View
@@ -116,16 +116,20 @@ run_sinan() ->
%% command line args
-spec run_sinan([string()]) -> sin_config:config().
run_sinan(Args) ->
- manual_start(),
- case getopt:parse(option_spec_list(), Args) of
- {ok, {Options, [Target | Rest]}} ->
- do_internal(erlang:list_to_atom(Target), Rest, Options);
- {ok, {Options, []}} ->
- do_internal(undefined, [], Options);
- {error, {Reason, Data}} ->
- io:format("Error: ~s ~p~n~n", [Reason, Data]),
- usage(),
- {error, failed}
+ case manual_start() of
+ ok ->
+ case getopt:parse(option_spec_list(), Args) of
+ {ok, {Options, [Target | Rest]}} ->
+ do_internal(erlang:list_to_atom(Target), Rest, Options);
+ {ok, {Options, []}} ->
+ do_internal(undefined, [], Options);
+ {error, {Reason, Data}} ->
+ io:format("Error: ~s ~p~n~n", [Reason, Data]),
+ usage(),
+ {error, failed}
+ end;
+ Else ->
+ Else
end.
@@ -134,34 +138,39 @@ run_sinan(Args) ->
%%% and all dependencies
-spec manual_start() -> ok.
manual_start() ->
- lists:foreach(fun(App) ->
- case application:start(App) of
- {error, {already_started, App}} ->
- ok;
- ok ->
- ok;
- Error ->
- throw(Error)
- end
- end,
- [kernel,
- stdlib,
- cucumberl,
- erlware_commons,
- compiler,
- syntax_tools,
- edoc,
- eunit,
- tools,
- xmerl,
- mnesia,
- parsetools,
- getopt,
- crypto,
- proper,
- erlware_commons,
- joxa,
- sinan]).
+ lists:foldl(fun(App, ok) ->
+ case application:start(App) of
+ {error, {already_started, App}} ->
+ ok;
+ ok ->
+ ok;
+ Error ->
+ io:format("Error starting OTP Application ~p~n",
+ [Error]),
+ Error
+ end;
+ (_App, Else) ->
+ Else
+ end,
+ ok,
+ [kernel,
+ stdlib,
+ cucumberl,
+ erlware_commons,
+ compiler,
+ syntax_tools,
+ edoc,
+ eunit,
+ tools,
+ xmerl,
+ mnesia,
+ parsetools,
+ getopt,
+ crypto,
+ proper,
+ erlware_commons,
+ joxa,
+ sinan]).
-spec usage() -> ok.
usage() ->

0 comments on commit dd5c2f4

Please sign in to comment.