anchor.diff:      true ->
           []
       end,
  -    send_error(Req, Code, Headers, ErrorStr, ReasonStr).
  +    send_error(Req, Code, Headers, ErrorStr, ReasonStr, json_stack(Error)).
   
   send_error(Req, Code, ErrorStr, ReasonStr) ->
  -    send_error(Req, Code, [], ErrorStr, ReasonStr).
  -
  -send_error(Req, Code, Headers, ErrorStr, ReasonStr) ->
  +    send_error(Req, Code, ErrorStr, ReasonStr, []).
  +
  +send_error(Req, Code, ErrorStr, ReasonStr, Stack) ->
  +    send_error(Req, Code, [], ErrorStr, ReasonStr, Stack).
  +
  +send_error(Req, Code, Headers, ErrorStr, ReasonStr, Stack) ->
       send_json(Req, Code, Headers,
           {[{<<"error">>,  ErrorStr},
  -         {<<"reason">>, ReasonStr}]}).
  +         {<<"reason">>, ReasonStr},
  +         {stack, Stack}]}).
   
   % give the option for list functions to output html or other raw errors
   send_chunked_error(Resp, {_Error, {[{<<"body">>, Reason}]}}) ->
  
positive.code: 
  reqid() ->
      {"X-Couch-Request-ID", get(nonce)}.
  
negative.code:             send_error(HttpReq, Error);
          error:database_does_not_exist ->
              send_error(HttpReq, database_does_not_exist);
          Tag:Error ->
              ?LOG_ERROR("Uncaught error in HTTP request: ~p",[{Tag, Error}]),
              Stack = erlang:get_stacktrace(),
              ?LOG_INFO("Stacktrace: ~p",[Stack]),
              send_error(HttpReq, {Error, nil, Stack})
      end,
  
      RequestTime = timer:now_diff(now(), Begin)/1000,
  