emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/rt-liberation 246acd2 06/72: * rt-liberation.el: Attemp


From: Stefan Monnier
Subject: [elpa] externals/rt-liberation 246acd2 06/72: * rt-liberation.el: Attempt to handle server response when assigning.
Date: Wed, 5 Aug 2020 11:57:32 -0400 (EDT)

branch: externals/rt-liberation
commit 246acd2c960c57a678640aaf5ce6993b72b2e67a
Author: Yoni Rabkin <yonirabkin@member.fsf.org>
Commit: Yoni Rabkin <yonirabkin@member.fsf.org>

    * rt-liberation.el: Attempt to handle server response when assigning.
---
 rt-liberation.el | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/rt-liberation.el b/rt-liberation.el
index 1ff4389..995a767 100644
--- a/rt-liberation.el
+++ b/rt-liberation.el
@@ -1202,14 +1202,28 @@ If FIELD already exists, update to VALUE."
   (rt-liber-command-set-status
    id (rt-liber-command-get-status-string 'open)))
 
+;; This is brittle because the server doesn't respond with a code but
+;; with some free text, and we have no guarantee that the text will be
+;; stable from version to version.
+(defun rt-liber-handle-response-set-owner (response)
+  "Handle the response from the RT server. Pass on the response."
+  (when
+      (with-temp-buffer
+       (insert response)
+       (goto-char (point-min))
+       (re-search-forward "That user does not exist" (point-max) t))
+    (error "that user does not exist"))
+  response)
+
 (defun rt-liber-command-set-owner (id owner)
   "Set the owner of ticket ID to OWNER."
   (let ((command (rt-liber-command-get-command-string 'edit))
        (args
         (format "ticket/%s set owner=%s" id owner)))
-    (rt-liber-parse-answer
-     (rt-liber-command-runner command args)
-     'rt-liber-command-runner-parser-f)))
+    (rt-liber-handle-response-set-owner
+     (rt-liber-parse-answer
+      (rt-liber-command-runner command args)
+      'rt-liber-command-runner-parser-f))))
 
 (defun rt-liber-command-set-queue (id queue)
   "Set the queue of ticket ID to QUEUE."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]