anchor.diff:  
   reqid() ->
       {"X-Couch-Request-ID", get(nonce)}.
  +
  +json_stack({_Error, _Reason, Stack}) ->
  +    lists:map(fun({M,F,A0}) ->
  +        A = if is_integer(A0) -> A0; is_list(A0) -> length(A0); true -> 0 end,
  +        list_to_binary(io_lib:format("~s:~s/~B", [M,F,A]));
  +    (_) ->
  +        <<"bad entry in stacktrace">>
  +    end, Stack);
  +json_stack(_) ->
  +    [].
  
positive.code:             send_error(HttpReq, Error);
          error:database_does_not_exist ->
              send_error(HttpReq, database_does_not_exist);
          error:badarg ->
              ?LOG_ERROR("Badarg error in HTTP request",[]),
              ?LOG_INFO("Stacktrace: ~p",[erlang:get_stacktrace()]),
              send_error(HttpReq, badarg);
          error:function_clause ->
              ?LOG_ERROR("function_clause error in HTTP request",[]),
              ?LOG_INFO("Stacktrace: ~p",[erlang:get_stacktrace()]),
              send_error(HttpReq, function_clause);
          Tag:Error ->
              ?LOG_ERROR("Uncaught error in HTTP request: ~p",[{Tag, Error}]),
              ?LOG_INFO("Stacktrace: ~p",[erlang:get_stacktrace()]),
              send_error(HttpReq, Error)
      end,
  
      RequestTime = timer:now_diff(now(), Begin)/1000,
  
negative.code:     {Code, ErrorStr, ReasonStr} = error_info(Error),
      JsonError = {[{<<"code">>, Code},
          {<<"error">>,  ErrorStr},
          {<<"reason">>, ReasonStr},
          {stack, json_stack(Error)}]},
      send_chunk(Resp, ?l2b([$\n,?JSON_ENCODE(JsonError),$\n])),
      send_chunk(Resp, []).
  
  