1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 08156431FBD
\r
6 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:16 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id a+42A1gttsWM for <notmuch@notmuchmail.org>;
\r
16 Sat, 1 Dec 2012 18:40:15 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id CA33A431FC3
\r
20 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:13 -0800 (PST)
\r
21 X-AuditID: 12074425-b7f606d0000008ea-2a-50babf8d2d00
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 19.75.02282.D8FBAB05; Sat, 1 Dec 2012 21:40:13 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id qB22eBuO030585;
\r
27 Sat, 1 Dec 2012 21:40:11 -0500
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qB22e65n025605
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 1 Dec 2012 21:40:10 -0500 (EST)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1TezTS-0000xn-55; Sat, 01 Dec 2012 21:40:06 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 09/10] emacs: Improve error handling for
\r
41 notmuch-call-notmuch-json
\r
42 Date: Sat, 1 Dec 2012 21:40:01 -0500
\r
43 Message-Id: <1354416002-3557-9-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10.4
\r
45 In-Reply-To: <1354416002-3557-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1354416002-3557-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsUixCmqrdu7f1eAwcNOQYvrN2cyOzB6PFt1
\r
49 izmAMYrLJiU1J7MstUjfLoEr49v2s0wFiwUrNtz/wdjAOJe3i5GDQ0LARGLZDLsuRk4gU0zi
\r
50 wr31bF2MXBxCAvsYJdYfnskK4axnlJjVfpsFwnnIJLFk8z82kBYhgbmMEvfv5YLYbAIaEtv2
\r
51 L2cEsUUEpCV23p3NCrKBWUBN4k+XCkhYWCBIou/XVBYQm0VAVWLPpG+sIDavgL1E05Z2Rogr
\r
52 FCW6n01gA2nlFHCQWNHNA7HJXuL/72tsExj5FzAyrGKUTcmt0s1NzMwpTk3WLU5OzMtLLdK1
\r
53 0MvNLNFLTSndxAgKGHYX1R2MEw4pHWIU4GBU4uGNmLMrQIg1say4MvcQoyQHk5Io75UdQCG+
\r
54 pPyUyozE4oz4otKc1OJDjBIczEoivCwmQDnelMTKqtSifJiUNAeLkjjvjZSb/kIC6Yklqdmp
\r
55 qQWpRTBZGQ4OJQne6n1AjYJFqempFWmZOSUIaSYOTpDhPEDDp4HU8BYXJOYWZ6ZD5E8xKkqJ
\r
56 83aCJARAEhmleXC9sIh+xSgO9Iow72GQKh5gMoDrfgU0mAlo8Jtl20EGlyQipKQaGJOVBBMK
\r
57 TfYoSGovuVzmbLuXuXiL1JH3H+xWaMTN6CybsbU4ZePxZQYXJB/uTmpR0tBY2hyyeGVlbJzA
\r
58 H225/jv3HF+ohok8SqvPu2ZXyb6Rs1bZNPXQjPTlM2/aLfFuETLZZ3Pkw+ZbyU8ONPF9lOUt
\r
59 vcRZFiHF98nlxuVTDW36k2dcdfu7XImlOCPRUIu5qDgRAE9JeV/DAgAA
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Sun, 02 Dec 2012 02:40:16 -0000
\r
74 This checks for non-zero exit status and pops up an error buffer
\r
75 giving the exit status, the stderr, and the stdout. Schema version
\r
76 mismatches are handled specially.
\r
78 emacs/notmuch-lib.el | 40 +++++++++++++++++++++++++++++++++-------
\r
79 1 file changed, 33 insertions(+), 7 deletions(-)
\r
81 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
82 index 31c69dc..9c6be13 100644
\r
83 --- a/emacs/notmuch-lib.el
\r
84 +++ b/emacs/notmuch-lib.el
\r
85 @@ -361,15 +361,41 @@ You may need to restart Emacs or upgrade your notmuch package."))
\r
86 "Invoke `notmuch-command' with `args' and return the parsed JSON output.
\r
88 The returned output will represent objects using property lists
\r
89 -and arrays as lists."
\r
90 +and arrays as lists. If notmuch exits with a non-zero status,
\r
91 +this will pop up a buffer containing notmuch's output and signal
\r
95 - (apply #'call-process notmuch-command nil (list t nil) nil args)
\r
96 - (goto-char (point-min))
\r
97 - (let ((json-object-type 'plist)
\r
98 - (json-array-type 'list)
\r
99 - (json-false 'nil))
\r
101 + (let ((err-file (make-temp-file "nmerr")))
\r
103 + (let ((status (apply #'call-process
\r
104 + notmuch-command nil (list t err-file) nil args)))
\r
105 + (cond ((equal status 0)
\r
106 + (goto-char (point-min))
\r
107 + (let ((json-object-type 'plist)
\r
108 + (json-array-type 'list)
\r
109 + (json-false 'nil))
\r
111 + ((or (equal status 20) (equal status 21))
\r
112 + ;; Special handling of version mismatch errors
\r
113 + (notmuch-version-mismatch-error status))
\r
115 + (goto-char (point-min))
\r
116 + (insert "Error:\n")
\r
117 + (let ((pos (point)))
\r
118 + (insert-file-contents err-file)
\r
119 + (when (= (point) pos)
\r
120 + (insert "(no error output)\n")))
\r
122 + (insert "Output:\n"))
\r
123 + (notmuch-pop-up-error
\r
125 + (format "CLI error. %S exited with %s%s.\n"
\r
126 + (cons notmuch-command args)
\r
127 + (if (integerp status) "status " "")
\r
129 + (buffer-string))))))
\r
130 + (delete-file err-file)))))
\r
132 ;; Compatibility functions for versions of emacs before emacs 23.
\r