Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 3C050431FD2 for ; Sun, 29 Jan 2012 17:55:04 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1+znGtMwX4pg for ; Sun, 29 Jan 2012 17:55:03 -0800 (PST) Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU [18.7.68.37]) by olra.theworths.org (Postfix) with ESMTP id 9DAA3431FBC for ; Sun, 29 Jan 2012 17:55:03 -0800 (PST) X-AuditID: 12074425-b7f4a6d0000008e0-06-4f25f875f5d8 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id 6D.83.02272.578F52F4; Sun, 29 Jan 2012 20:55:02 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q0U1t1Km006178; Sun, 29 Jan 2012 20:55:01 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0U1sxwr026535 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 29 Jan 2012 20:55:00 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1RrgRf-0000LO-Dt; Sun, 29 Jan 2012 20:54:11 -0500 Date: Sun, 29 Jan 2012 20:54:11 -0500 From: Austin Clements To: Justus Winter <4winter@informatik.uni-hamburg.de> Subject: Re: error handling and stderr Message-ID: <20120130015411.GL17991@mit.edu> References: <20120129180124.23430.33656@thinkbox.jade-hamburg.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120129180124.23430.33656@thinkbox.jade-hamburg.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hTV1i37oepv8Okoo8Xs1h9MFtdvzmR2 YPKYeP40m8ezVbeYA5iiuGxSUnMyy1KL9O0SuDIev5At2CRScfPAKaYGxo0CXYycHBICJhIP L99mgrDFJC7cW8/WxcjFISSwj1Hi7+0mKGcDo0RLZzMLhHOSSeL3jrXMEM4SRomDrVPYQPpZ BFQlTk9+yAxiswloSGzbv5wRxBYRMJXY8OABO4jNLGAkcX/HdLAaYQE1iSNdq1hBbF4BHYnZ 786DzREScJTYfuQPO0RcUOLkzCcsEL1aEjf+vQS6lQPIlpZY/o8DJMwp4CRx/9A7sJGiAioS U05uY5vAKDQLSfcsJN2zELoXMDKvYpRNya3SzU3MzClOTdYtTk7My0st0rXQy80s0UtNKd3E CAprdhfVHYwTDikdYhTgYFTi4d1ZoeovxJpYVlyZe4hRkoNJSZTX9TtQiC8pP6UyI7E4I76o NCe1+BCjBAezkgjvnGVAOd6UxMqq1KJ8mJQ0B4uSOK+m1js/IYH0xJLU7NTUgtQimKwMB4eS BO9xkKGCRanpqRVpmTklCGkmDk6Q4TxAw6+B1PAWFyTmFmemQ+RPMSpKifNuBkkIgCQySvPg emFp5xWjONArwrybQKp4gCkLrvsV0GAmoMHPGcAGlyQipKQaGEWP3juy8O/sA28UZE2YuSZO uXd8x37bA/5LmZRztjO0fuiaZm73+GLF46tNs/I6DHqbEjns30lsn9Yk8HHmYkGTK3vCQr2P 7Ew5IsrI6CUp/2wpV6X/1KqDwdN9NfYFuAfK+d9eZWC3J1ebTd6F+ajz1BOqbGpi+5z1GAWl haS8leMOztv4QomlOCPRUIu5qDgRAN2neF0WAwAA Cc: notmuch mailing list X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jan 2012 01:55:04 -0000 Quoth Justus Winter on Jan 29 at 7:01 pm: > Hi notmuch developers, > > currently there is no way to determine why opening a database using > notmuch_database_open fails. I suppose that this is a problem for all > functions returning a pointer, but it is especially problematic for > this function since one cannot distinguish between a temporary failure > (someone else opened the db read/write) and a configuration problem > (wrong path). > > This is a real problem for providing sensible feedback to the user. I'm in the process of fixing the temporary failure, which I suspect is the biggest problem with the lack of status return, but you're right that a function as involved as notmuch_database_open really needs a way to distinguish failure types. Carl even left a note about this in notmuch.h in 2009. We could fix this without breaking the API by introducing a second variant of notmuch_database_open. I'm actually not a fan of this; I think notmuch is young enough and the library has few enough consumers that it's pointless to lug around compatibility code when the alternative is distinctly better. If we're really concerned about compatibility, I think we should move to using versioned symbols. > And writing an error message to stderr is a sensible thing to do if it > is done in a command line utility but doing so within a library is a > severe problem for any curses frontends and is generally considered a > bad practice. This is an unfortunate consequence of C's terrible error handling. I don't know how to do this effectively if we want error messages to accompany errors (which account for almost, though not quite all prints to stderr from libnotmuch). We could maintain a "last error message" on the database object, but then we have to be sure to update this on any error. We could simply provide a log hook. It's not very satisfying, but it may address the immediate problem of corrupting curses displays. What I find most frustrating about the current error handling approach is that it's always unclear whether a caller should report an error message or if the callee has already taken care of it (and generally with greater detail). Log hooks don't particularly help with this. > For the record, libabcs README[0] agrees with me on both aspects. > > Since fixing this means breaking the api we need to discuss this > thoroughly and identify all the functions involved. > > Users of the python bindings won't be affected by an api change like > this since we're converting any error code to exceptions anyway.