[erlang-questions] catch
Wes James
comptekki@REDACTED
Wed Mar 2 20:05:14 CET 2011
On Wed, Mar 2, 2011 at 2:07 AM, Attila Rajmund Nohl
<attila.r.nohl@REDACTED> wrote:
<snip>
>
> Haven't tested (or even compiled), but a lot clearer:
>
> main([""]) ->
> io:format("~nDid you forget the number?~n~n");
> main([String]) ->
> try
> I=list_to_integer(String),
> Seq=lists:seq(I+1, I+20),
> lists:foreach(fun(H) -> io:format("#./runcscript ~p ~n",[H]) end, Seq)
> catch
> error:{badarg,_} ->
> io:format("~n~p~n~n",["Arg not Int"])
> end;
> main(_) ->
> io:format("~nDid you forget the number?~n~n").
>
escript script.erl 'a'
escript: exception error: bad argument
More information about the erlang-questions
mailing list