[erlang-questions] http:request

Carlo Bertoldi carlo.bertoldi@REDACTED
Fri Apr 22 09:37:50 CEST 2011


Il 21/04/2011 17:10, Carlo Bertoldi ha scritto:
> Good afternoon,
>  I have a problem with http:request.
>
<snip>
>
> Result = http:request(get, {CompleteUrl, [{"User-Agent", "Erl-bot"}]}, 
> [], []),
> io:format("Result = ~p~n", [Result]).
>
> Occasionally I don't see Result printed, but a nice error:
> ** Reason for termination ==
> ** {{badmatch,{16,6,18}},

Hello, I discovered the cause of the badmatch: it was due to the debug 
macro I've defined.
Here it is:

-define(DBG(Str, Args),
   {Year, Month, Day} = date(),
   {Hour, Min, Sec} = time(),
   io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] - 
", [Day, Month,
        Year, Hour, Min, Sec, ?MODULE, ?LINE]), io:format(Str, Args)).

Can someone explain me what I did wrong here? Why should I obtain a 
badmatch on {Hour, Min, Sec} = time() ?

Thank you,
  Carlo



More information about the erlang-questions mailing list