bin/doom: improve error output

Show different message for straight errors (but log backtrace to
doom.error.log either way).
This commit is contained in:
Henrik Lissner 2020-08-28 01:12:28 -04:00
parent 4dc888d104
commit 5de08af8da
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -247,31 +247,30 @@ BODY will be run when this dispatcher is called."
;; ;;
;;; Debugger ;;; Debugger
(defun doom-cli--debugger (&rest args) (cl-defun doom-cli--debugger (error data)
(cl-incf num-nonmacro-input-events) (cl-incf num-nonmacro-input-events)
(cl-destructuring-bind (error data backtrace) (cl-destructuring-bind (backtrace &optional type data . _)
(list (caadr args) (cons (doom-cli--backtrace) data)
(cdadr args) (cond
(doom-cli--backtrace)) ((and (bound-and-true-p straight-process-buffer)
(print! (error "There was an unexpected error")) (stringp data)
(string-match-p (regexp-quote straight-process-buffer)
data))
(print! (error "There was an unexpected package error"))
(print-group! (print-group!
(print! "%s %s" (bold "Message:") (get error 'error-message)) (print! "%s" (string-trim-right (straight--process-get-output)))))
(print! "%s %S" (bold "Data:") (cons error data)) ((print! (error "There was an unexpected error"))
(when (and (bound-and-true-p straight-process-buffer)
(ignore-errors
(string-match-p "straight" (car data))))
(print! (bold "Straight output:"))
(let ((output (straight--process-get-output)))
(appendq! data (list (cons "STRAIGHT" output)))
(print-group! (print-group!
(print! "%s" (string-trim-right output))))) (print! "%s %s" (bold "Message:") (get type 'error-message))
(print! "%s %S" (bold "Data:") (cons type data))
(when backtrace (when backtrace
(print! (bold "Backtrace:")) (print! (bold "Backtrace:"))
(print-group! (print-group!
(dolist (frame (seq-take backtrace 10)) (dolist (frame (seq-take backtrace 10))
(print! (print!
"%0.74s" (replace-regexp-in-string "%0.74s" (replace-regexp-in-string
"[\n\r]" "\\\\n" (format "%S" frame))))) "[\n\r]" "\\\\n" (format "%S" frame)))))))))
(when backtrace
(with-temp-file doom-cli-log-error-file (with-temp-file doom-cli-log-error-file
(insert "# -*- lisp-interaction -*-\n") (insert "# -*- lisp-interaction -*-\n")
(insert "# vim: set ft=lisp:\n") (insert "# vim: set ft=lisp:\n")
@ -281,9 +280,9 @@ BODY will be run when this dispatcher is called."
(print-escape-control-characters t) (print-escape-control-characters t)
(print-level nil) (print-level nil)
(print-circle nil)) (print-circle nil))
(mapc #'print (cons (list error data) backtrace))) (mapc #'print (cons (list type data) backtrace)))
(print! (warn "Extended backtrace logged to %s") (print! (warn "Extended backtrace logged to %s")
(relpath doom-cli-log-error-file)))))) (relpath doom-cli-log-error-file)))))
(throw 'exit 255)) (throw 'exit 255))
(defun doom-cli--backtrace () (defun doom-cli--backtrace ()