couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filipe David Manana <>
Subject Re: Ang.: Re: using Erlang's debugger with couchdb
Date Fri, 04 Dec 2009 18:48:59 GMT
thanks for the suggestion Torbjörn, I had not yet the time to test it
but it seems promising (I am mostly an Emacs user also). It's on my
todo list now.

I found the cause of the problem. When debugging using Erlang's
debugger, he considers the Length variable used in the second case
statement  (attribution to #att.len) to be already bound. This is so
because the previous case statement also uses a variable named Length
in 2 of its branches.

Just renaming the second one from Length to Length2
(chouch_httpd_db.erl line 1045) avoids the badmatch error:

                name = FileName,
                type = case couch_httpd:header_value(Req,"Content-Type") of
                    undefined ->
                        % We could throw an error here or guess by the FileName.
                        % Currently, just giving it a default.
                    CType ->
                data = case couch_httpd:body_length(Req) of
                    undefined ->
                    {unknown_transfer_encoding, Unknown} ->
                        exit({unknown_transfer_encoding, Unknown});
                    chunked ->
                        fun(MaxChunkSize, ChunkFun, InitState) ->
                            couch_httpd:recv_chunked(Req, MaxChunkSize,
                                ChunkFun, InitState)
                    0 ->
                    Length when is_integer(Length) ->
                        fun() -> couch_httpd:recv(Req, 0) end;
                    Length ->
                        exit({length_not_integer, Length})
                len = case couch_httpd:header_value(Req,"Content-Length") of
                    undefined ->
                    Length2 ->

I wonder why this badmatch error only occurs when interpreting the
code with the debugger and not during normal execution.
Anyone has a clue?


2009/12/2 Torbjörn Törnkvist <>:
> For some more light weight debugging I can recomend redbug.  It is included
> in the eper repo at google code.
> --Tobbe
> Den 12 1, 2009 11:50 PM, "Robert Dionne" <>
> skrev:
> I've had great luck using Distel[1]  on top of aquamacs. Bill Clementson
> wrote a couple of nice how to pieces[2] to get you started. Works like a
> champ
> [1]
> [2]
> On Dec 1, 2009, at 5:34 PM, Filipe David Manana wrote: > Hello, > > I am
> having a strange sit...

Filipe David Manana,
PGP key -

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

View raw message