all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lennart Borgman <lennart.borgman.073@student.lu.se>
Subject: Displaying errors during startup
Date: Wed, 26 Apr 2006 17:13:43 +0200	[thread overview]
Message-ID: <444F8E27.10501@student.lu.se> (raw)

After the recent discussion about error messages at startup (this time 
it was about pure-space-overflow) it came to my mind I often tend to 
miss errors at startup. You can not see them because of the splash 
screen for example. I just started testing `lwarn' because of this. I 
did something like this:

    (condition-case err
        (require 'something-bad)
      (error
       (lwarn '(.emacs) :error "%s" (error-message-string err))))

This displays the error in a nice way even during startup. Looking a bit 
closer at it it seems to be some trouble with using `pop-to-buffer' in 
startup.el when loading .emacs. I therefore suggest using 
`display-buffer' instead like lwarn does. It would also be nice to have 
a more visible face when putting this in the message buffer. I therefore 
suggest using something like the code below in startup.el (around line 905):

  (if init-file-debug
      (load inner)
    (condition-case error
        (load inner)
      (error
       (let ((message-log-max nil))
         (save-excursion
           (set-buffer (get-buffer-create "*Messages*"))
           (let ((s
                  (concat
                   "\n\n"
                   (format "An error has occurred while loading `%s':\n\n"
                           user-init-file)
                   (format "%s%s%s"
                           (get (car error) 'error-message)
                           (if (cdr error) ": " "")
                           (mapconcat (lambda (s) (prin1-to-string s t)) 
(cdr error) ", "))
                   "\n\n"
                   "To ensure normal operation, you should investigate 
and remove the\n"
                   "cause of the error in your initialization file.  
Start Emacs with\n"
                   "the `--debug-init' option to view a complete error 
backtrace.\n\n")))
             (put-text-property
              0 (length s)
              'face 'font-lock-warning-face
              s)
             (insert s)
             (insert "\n") ;; Needed to get normal face again.
             (message "Error in init file: %s%s%s"
                      (get (car error) 'error-message)
                      (if (cdr error) ": " "")
                      (mapconcat 'prin1-to-string (cdr error) ", "))
             ;;(let ((pop-up-windows nil))
             ;;  (pop-to-buffer "*Messages*"))
             (display-buffer "*Messages*") ;; display-buffer does the job.
             (sit-for 10) ;; sit-for is necessary to display the info at 
once.
             (setq init-file-had-error t)))))))

Maybe this would be good to do before the release because it makes it 
somewhat easier to trap errors.

             reply	other threads:[~2006-04-26 15:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-26 15:13 Lennart Borgman [this message]
2006-04-26 18:41 ` Displaying errors during startup Kevin Rodgers
2006-04-27 21:27 ` Richard Stallman
2006-04-27 21:34   ` Lennart Borgman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=444F8E27.10501@student.lu.se \
    --to=lennart.borgman.073@student.lu.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.