From a228d1941dfdc013efd7fe0e18eb42021540c0ae Mon Sep 17 00:00:00 2001 From: Daniel Pettersson Date: Mon, 7 Oct 2024 18:32:15 +0200 Subject: [PATCH] Improve user-error on missing live connections --- dape.el | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/dape.el b/dape.el index bdf7a3b2..5a0806d1 100644 --- a/dape.el +++ b/dape.el @@ -1290,21 +1290,20 @@ See `dape--connection-selected'." (reverse connections)))) (conn (pcase type - ('parent - (car connections)) - ('last - (seq-find 'dape--thread-id ordered)) - ('running - (seq-find (lambda (conn) - (and (dape--thread-id conn) - (not (dape--stopped-threads conn)))) - ordered)) - ('stopped - (seq-find (lambda (conn) - (and (dape--stopped-threads conn))) - ordered))))) + ('parent (car connections)) + ('last (seq-find #'dape--thread-id ordered)) + ('running (seq-find (lambda (conn) + (and (dape--thread-id conn) + (not (dape--stopped-threads conn)))) + ordered)) + ('stopped (seq-find (lambda (conn) + (and (dape--stopped-threads conn))) + ordered))))) (unless (or nowarn conn) - (user-error "No %s debug connection live" type)) + (user-error "No %sdebug connection live" + ;; `parent' and `last' does not make sense to the user + (if (memq type '(running stopped)) + (format "%s " type) ""))) conn)) (defun dape--live-connections ()