branch: externals/plz
commit 7d197e968af6ee31b501d43a76afc7059609307d
Author: Adam Porter <[email protected]>
Commit: Adam Porter <[email protected]>
Change: (plz--respond) Don't catch errors from THEN/ELSE
This wasn't really a good idea, but since we're now using a timer, it
isn't needed, anyway.
---
plz.el | 94 ++++++++++++++++++++++++++++++------------------------------------
1 file changed, 42 insertions(+), 52 deletions(-)
diff --git a/plz.el b/plz.el
index b51193a2f1..edff6ac9e6 100644
--- a/plz.el
+++ b/plz.el
@@ -770,58 +770,48 @@ argument passed to `plz--sentinel', which see."
(unwind-protect
(with-current-buffer buffer
(setf sync plz-sync)
- (condition-case err
- (pcase-exhaustive status
- ((or 0 "finished\n")
- ;; Curl exited normally: check HTTP status code.
- (goto-char (point-min))
- (plz--skip-proxy-headers)
- (while (plz--skip-redirect-headers))
- (pcase (plz--http-status)
- ((and status (guard (<= 200 status 299)))
- ;; Any 2xx response is considered successful.
- (ignore status) ; Byte-compiling in Emacs <28 complains
without this.
- (funcall plz-then))
- (_
- ;; FIXME: If using ":as 'response", the HTTP
- ;; response should be passed to the THEN function,
- ;; regardless of the status code. Only for curl
- ;; errors should the ELSE function be called.
-
- ;; Any other status code is considered unsuccessful
- ;; (for now, anyway).
- (let ((err (make-plz-error :response (plz--response))))
- (pcase-exhaustive plz-else
- (`nil (process-put process :plz-result err))
- ((pred functionp) (funcall plz-else err)))))))
-
- ((or (and (pred numberp) code)
- (rx "exited abnormally with code " (let code (group (1+
digit)))))
- ;; Curl error.
- (let* ((curl-exit-code (cl-typecase code
- (string (string-to-number code))
- (number code)))
- (curl-error-message (alist-get curl-exit-code
plz-curl-errors))
- (err (make-plz-error :curl-error (cons curl-exit-code
curl-error-message))))
- (pcase-exhaustive plz-else
- (`nil (process-put process :plz-result err))
- ((pred functionp) (funcall plz-else err)))))
-
- ((and (or "killed\n" "interrupt\n") status)
- ;; Curl process killed or interrupted.
- (let* ((message (pcase status
- ("killed\n" "curl process killed")
- ("interrupt\n" "curl process interrupted")))
- (err (make-plz-error :message message)))
- (pcase-exhaustive plz-else
- (`nil (process-put process :plz-result err))
- ((pred functionp) (funcall plz-else err))))))
- (error
- ;; Error signaled by a function called to process HTTP response:
- ;; rather than signaling an error from within the sentinel,
- ;; return or call the ELSE function with a plz-error struct.
- (let ((err (make-plz-error :message (format "plz--sentinel: Error
signaled: %S REQUEST-ARGS:%S"
- err (process-get
process :plz-args)))))
+ (pcase-exhaustive status
+ ((or 0 "finished\n")
+ ;; Curl exited normally: check HTTP status code.
+ (goto-char (point-min))
+ (plz--skip-proxy-headers)
+ (while (plz--skip-redirect-headers))
+ (pcase (plz--http-status)
+ ((and status (guard (<= 200 status 299)))
+ ;; Any 2xx response is considered successful.
+ (ignore status) ; Byte-compiling in Emacs <28 complains
without this.
+ (funcall plz-then))
+ (_
+ ;; FIXME: If using ":as 'response", the HTTP
+ ;; response should be passed to the THEN function,
+ ;; regardless of the status code. Only for curl
+ ;; errors should the ELSE function be called.
+
+ ;; Any other status code is considered unsuccessful
+ ;; (for now, anyway).
+ (let ((err (make-plz-error :response (plz--response))))
+ (pcase-exhaustive plz-else
+ (`nil (process-put process :plz-result err))
+ ((pred functionp) (funcall plz-else err)))))))
+
+ ((or (and (pred numberp) code)
+ (rx "exited abnormally with code " (let code (group (1+
digit)))))
+ ;; Curl error.
+ (let* ((curl-exit-code (cl-typecase code
+ (string (string-to-number code))
+ (number code)))
+ (curl-error-message (alist-get curl-exit-code
plz-curl-errors))
+ (err (make-plz-error :curl-error (cons curl-exit-code
curl-error-message))))
+ (pcase-exhaustive plz-else
+ (`nil (process-put process :plz-result err))
+ ((pred functionp) (funcall plz-else err)))))
+
+ ((and (or "killed\n" "interrupt\n") status)
+ ;; Curl process killed or interrupted.
+ (let* ((message (pcase status
+ ("killed\n" "curl process killed")
+ ("interrupt\n" "curl process interrupted")))
+ (err (make-plz-error :message message)))
(pcase-exhaustive plz-else
(`nil (process-put process :plz-result err))
((pred functionp) (funcall plz-else err)))))))