From 8b5428d320b1a8daa3d07737a6eeb823a22d71b1 Mon Sep 17 00:00:00 2001 From: justbur Date: Mon, 12 Oct 2015 09:07:48 -0400 Subject: [PATCH] core-dotspacemacs: Make call-func macro safer Catch errors in executed function and signal them to the user in the spacemacs buffer. We don't want loading to silently fail because there is a problem in dotspacemacs/user-config for example. --- core/core-dotspacemacs.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/core-dotspacemacs.el b/core/core-dotspacemacs.el index c30200823..1360c38ca 100644 --- a/core/core-dotspacemacs.el +++ b/core/core-dotspacemacs.el @@ -401,10 +401,18 @@ error recovery." (defmacro dotspacemacs|call-func (func &optional msg) "Call the function from the dotfile only if it is bound. -If MSG is not nil then display a message in `*Messages'." +If MSG is not nil then display a message in `*Messages'. Errors +are caught and signalled to user in spacemacs buffer." `(progn (when ,msg (spacemacs-buffer/message ,msg)) - (if (fboundp ',func) (,func)))) + (when (fboundp ',func) + (condition-case-unless-debug err + (,func) + (error (spacemacs-buffer/append + (format "Error in %s: %s\n" + ',(symbol-name func) + (error-message-string err)) + t)))))) (defun dotspacemacs//test-dotspacemacs/layers () "Tests for `dotspacemacs/layers'"