Skip to content

Commit 08b154e

Browse files
committed
Improve completion error handling
1 parent 25e9f57 commit 08b154e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

eca-completion.el

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,14 @@ Call ON-ERROR when error."
176176
:success-callback (-lambda ((&plist :items items :error error))
177177
(if error
178178
(funcall on-error error)
179-
(funcall on-success items)))))))
179+
(funcall on-success items)))
180+
:error-callback (-lambda (error)
181+
(let ((type (plist-get error :type))
182+
(msg (plist-get error :message)))
183+
(pcase type
184+
("error" (eca-error msg))
185+
("warning" (eca-warn msg))
186+
("info" (eca-info msg)))))))))
180187

181188
(defun eca-completion--post-command-debounce (buffer)
182189
"Complete in BUFFER."
@@ -279,6 +286,7 @@ in `post-command-hook'."
279286
(defun eca-complete ()
280287
"Complete at the current point."
281288
(interactive)
289+
(eca-assert-session-running (eca-session))
282290
(setq eca-completion--last-doc-version eca-completion--doc-version)
283291

284292
;; TODO add cache
@@ -292,15 +300,7 @@ in `post-command-hook'."
292300
(if item
293301
(eca-completion--show-completion item)
294302
(when called-interactively
295-
(eca-warn "No completion is available.")))))
296-
:on-error
297-
(lambda (error)
298-
(let ((type (plist-get error :type))
299-
(msg (plist-get error :message)))
300-
(pcase type
301-
("error" (eca-error msg))
302-
("warning" (eca-warn msg))
303-
("info" (eca-info msg))))))))
303+
(eca-warn "No completion is available."))))))))
304304

305305
(provide 'eca-completion)
306306
;;; eca-completion.el ends here

0 commit comments

Comments
 (0)