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:
parent
4dc888d104
commit
5de08af8da
1 changed files with 34 additions and 35 deletions
|
@ -247,43 +247,42 @@ 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)
|
||||||
(print-group!
|
(string-match-p (regexp-quote straight-process-buffer)
|
||||||
(print! "%s %s" (bold "Message:") (get error 'error-message))
|
data))
|
||||||
(print! "%s %S" (bold "Data:") (cons error data))
|
(print! (error "There was an unexpected package error"))
|
||||||
(when (and (bound-and-true-p straight-process-buffer)
|
(print-group!
|
||||||
(ignore-errors
|
(print! "%s" (string-trim-right (straight--process-get-output)))))
|
||||||
(string-match-p "straight" (car data))))
|
((print! (error "There was an unexpected error"))
|
||||||
(print! (bold "Straight output:"))
|
(print-group!
|
||||||
(let ((output (straight--process-get-output)))
|
(print! "%s %s" (bold "Message:") (get type 'error-message))
|
||||||
(appendq! data (list (cons "STRAIGHT" output)))
|
(print! "%s %S" (bold "Data:") (cons type data))
|
||||||
|
(when backtrace
|
||||||
|
(print! (bold "Backtrace:"))
|
||||||
(print-group!
|
(print-group!
|
||||||
(print! "%s" (string-trim-right output)))))
|
(dolist (frame (seq-take backtrace 10))
|
||||||
(when backtrace
|
(print!
|
||||||
(print! (bold "Backtrace:"))
|
"%0.74s" (replace-regexp-in-string
|
||||||
(print-group!
|
"[\n\r]" "\\\\n" (format "%S" frame)))))))))
|
||||||
(dolist (frame (seq-take backtrace 10))
|
(when backtrace
|
||||||
(print!
|
(with-temp-file doom-cli-log-error-file
|
||||||
"%0.74s" (replace-regexp-in-string
|
(insert "# -*- lisp-interaction -*-\n")
|
||||||
"[\n\r]" "\\\\n" (format "%S" frame)))))
|
(insert "# vim: set ft=lisp:\n")
|
||||||
(with-temp-file doom-cli-log-error-file
|
(let ((standard-output (current-buffer))
|
||||||
(insert "# -*- lisp-interaction -*-\n")
|
(print-quoted t)
|
||||||
(insert "# vim: set ft=lisp:\n")
|
(print-escape-newlines t)
|
||||||
(let ((standard-output (current-buffer))
|
(print-escape-control-characters t)
|
||||||
(print-quoted t)
|
(print-level nil)
|
||||||
(print-escape-newlines t)
|
(print-circle nil))
|
||||||
(print-escape-control-characters t)
|
(mapc #'print (cons (list type data) backtrace)))
|
||||||
(print-level nil)
|
(print! (warn "Extended backtrace logged to %s")
|
||||||
(print-circle nil))
|
(relpath doom-cli-log-error-file)))))
|
||||||
(mapc #'print (cons (list error data) backtrace)))
|
|
||||||
(print! (warn "Extended backtrace logged to %s")
|
|
||||||
(relpath doom-cli-log-error-file))))))
|
|
||||||
(throw 'exit 255))
|
(throw 'exit 255))
|
||||||
|
|
||||||
(defun doom-cli--backtrace ()
|
(defun doom-cli--backtrace ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue