Include straight error in doom.error.log

This commit is contained in:
Henrik Lissner 2021-03-12 17:06:10 -05:00
parent d667a2a292
commit fc75573962

View file

@ -255,39 +255,42 @@ BODY will be run when this dispatcher is called."
(cl-incf num-nonmacro-input-events) (cl-incf num-nonmacro-input-events)
(cl-destructuring-bind (backtrace &optional type data . _) (cl-destructuring-bind (backtrace &optional type data . _)
(cons (doom-cli--backtrace) data) (cons (doom-cli--backtrace) data)
(cond (let ((straight-error-p
((and (bound-and-true-p straight-process-buffer) (and (bound-and-true-p straight-process-buffer)
(stringp data) (string-match-p (regexp-quote straight-process-buffer)
(string-match-p (regexp-quote straight-process-buffer) (or (get type 'error-message) "")))))
data)) (cond
(print! (error "There was an unexpected package error")) (straight-error-p
(when-let (output (straight--process-get-output)) (print! (error "There was an unexpected package error"))
(when-let (output (straight--process-get-output))
(print-group!
(print! "%s" (string-trim-right output)))))
((print! (error "There was an unexpected error"))
(print-group! (print-group!
(print! "%s" (string-trim-right output))))) (print! "%s %s" (bold "Message:") (get type 'error-message))
((print! (error "There was an unexpected error")) (print! "%s %S" (bold "Data:") (cons type data))
(print-group! (when backtrace
(print! "%s %s" (bold "Message:") (get type 'error-message)) (print! (bold "Backtrace:"))
(print! "%s %S" (bold "Data:") (cons type data)) (print-group!
(when backtrace (dolist (frame (seq-take backtrace 10))
(print! (bold "Backtrace:")) (print!
(print-group! "%0.74s" (replace-regexp-in-string
(dolist (frame (seq-take backtrace 10)) "[\n\r]" "\\\\n" (format "%S" frame)))))))))
(print! (when backtrace
"%0.74s" (replace-regexp-in-string (with-temp-file doom-cli-log-error-file
"[\n\r]" "\\\\n" (format "%S" frame))))))))) (insert "# -*- lisp-interaction -*-\n")
(when backtrace (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) (when straight-error-p
(print-level nil) (print (string-trim (or (straight--process-get-output) ""))))
(print-circle nil)) (mapc #'print (cons (list type 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 ()