<div><br></div><div><br></div>Hello all,<div><br></div><div>I need to see a backtrace of a cowboy_http_protocol:request/2 and to get it I've added some code in the function (marked strong):<br clear="all"><div style="text-align:left">
<br></div><div><div>request(_Any, State) -></div><div>%%%%%%%%%</div><div>   <b> io:format("~n~p~n", [{xxxxx161, State, _Any}]),</b></div><div><b>    try</b></div><div><b>        erlang:error(xxxxx161_error)</b></div>
<div><b>    catch</b></div><div><b>        error:X -></b></div><div><b>            io:format("~nxxxxx161_error stacktrace~n~p~n", [erlang:get_stacktrace()]),</b></div><div><b>            erlang:error(X)</b></div>
<div><b>    end,</b></div><div><b>%%%%%%%%%%%</b></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>error_terminate(400, State).</div></div><div><br></div><div><br></div><div>After recompilation and reloading I see only one line in backtrace list:</div>
<div><div><br></div><div>(web@AVINOKUROV)1> </div><div>{xxxxx161,</div><div>    {state,<0.85.0>,#Port<0.3809>,cowboy_tcp_transport,</div><div>        [{'_',</div><div>             [{[<<"token">>],</div>
<div>               ps_oauth_2_api_external_token_endpoint,</div><div>               [{config,off,off,</div><div>                    {{127,0,0,1},8080},</div><div>                    {{127,0,0,1},8180},</div><div>                    {{127,0,0,1},8443},</div>
<div>                    {{127,0,0,1},8543},</div><div>                    [{"jay","123"},"bob",{"matt","321"}],</div><div>                    "<a href="http://127.0.0.1:8881/client-storage">http://127.0.0.1:8881/client-storage</a>",</div>
<div>                    [{<<"apt1">>,{seconds,600,"600"}},</div><div>                     {<<"apt2">>,{seconds,6000,"6000"}}],</div><div>                    {seconds,3600,"3600"},</div>
<div>                    {seconds,600,"600"},</div><div>                    undefined,</div><div>                    {bytes,64},</div><div>                    {bytes,256},</div><div>                    {bytes,1024}},</div>
<div>                {external_api_applications,ps_oauth_2_ext_api_applications}]},</div><div>              {'_',ps_oauth_2_index,[external,#Fun<ps_oauth_2.2.99090327>]}]}],</div><div>        {ps_oauth_2_api_external_token_endpoint,</div>
<div>            [{config,off,off,</div><div>                 {{127,0,0,1},8080},</div><div>                 {{127,0,0,1},8180},</div><div>                 {{127,0,0,1},8443},</div><div>                 {{127,0,0,1},8543},</div>
<div>                 [{"jay","123"},"bob",{"matt","321"}],</div><div>                 "<a href="http://127.0.0.1:8881/client-storage">http://127.0.0.1:8881/client-storage</a>",</div>
<div>                 [{<<"apt1">>,{seconds,600,"600"}},</div><div>                  {<<"apt2">>,{seconds,6000,"6000"}}],</div><div>                 {seconds,3600,"3600"},</div>
<div>                 {seconds,600,"600"},</div><div>                 undefined,</div><div>                 {bytes,64},</div><div>                 {bytes,256},</div><div>                 {bytes,1024}},</div><div>
             {external_api_applications,ps_oauth_2_ext_api_applications}]},</div><div>        undefined,undefined,</div><div>        {#Fun<cowboy_http.urldecode.2>,crash},</div><div>        0,5,213,infinity,4096,5000,</div>
<div>        <<"authorization: Basic YXBwMToxMjM=\r\nconnection: keep-alive\r\n\r\ngrant_type=authorization_code&code=1pD8tsKZTFXw3sbbOPbLtCU0oSg5CWx%2FohR8AC%2BAuTROzsx1DQC6LLm4h6iaOvupV5cOs3cAqBqsWB%2BtzfxVtg%3D%3D">>,</div>
<div>        false,infinity,undefined},</div><div>    {http_error,<<"<a href="http://7.0.0.1:8080">7.0.0.1:8080</a>\r\n">>}}</div></div><div><br></div><div><div>(web@AVINOKUROV)1> </div><div>xxxxx161_error stacktrace</div>
<div>[{cowboy_http_protocol,request,2,</div><div>                       [{file,"src/cowboy_http_protocol.erl"},{line,172}]}]</div><div>(web@AVINOKUROV)1></div></div><div><div><br></div><div>=ERROR REPORT==== 17-Jul-2012::21:51:26 ===</div>
<div>Error in process <0.1373.0> on node 'web@AVINOKUROV' with exit value: {xxxxx161_error,[{cowboy_http_protocol,request,2,[{file,"src/cowboy_http_protocol.erl"},{line,176}]}]}</div></div><div><br>
</div><div><div>=SUPERVISOR REPORT==== 17-Jul-2012::21:51:26 ===</div><div>     Supervisor: {<0.86.0>,cowboy_requests_sup}</div><div>     Context:    child_terminated</div><div>     Reason:     {xxxxx161_error,</div>
<div>                     [{cowboy_http_protocol,request,2,</div><div>                          [{file,"src/cowboy_http_protocol.erl"},</div><div>                           {line,176}]}]}</div><div>     Offender:   [{pid,<0.1373.0>},</div>
<div>                  {name,cowboy_requests_sup},</div><div>                  {mfargs,{cowboy_requests_sup,start_request,undefined}},</div><div>                  {restart_type,temporary},</div><div>                  {shutdown,brutal_kill},</div>
<div>                  {child_type,worker}]</div></div><div><br></div><div>If I call that code in shell I see a full backtrace like that:</div><div><br></div><div><div>(web@AVINOKUROV)4> try</div><div>        erlang:error(xxxxxREQ_error)</div>
<div>    catch</div><div>        error:_ -></div><div>            io:format("~nxxxxxREQ_error stacktrace~n~p~n", [erlang:get_stacktrace()])</div><div>    end.</div><div><br></div><div>xxxxxREQ_error stacktrace</div>
<div>[{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,576}]},</div><div> {erl_eval,try_clauses,8,[{file,"erl_eval.erl"},{line,767}]},</div><div> {shell,exprs,7,[{file,"shell.erl"},{line,668}]},</div>
<div> {shell,eval_exprs,7,[{file,"shell.erl"},{line,623}]},</div><div> {shell,eval_loop,3,[{file,"shell.erl"},{line,608}]}]</div><div>ok</div><div>(web@AVINOKUROV)5> </div></div><div><br></div><div>
I don't understand what am I doing wrong.</div><div><br></div>-- <br><div>Александр Винокуров</div><div>+7 (921) 982-21-43</div><div>@aleksandrvin</div><br>
</div>