Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Created June 8, 2009 22:34
Show Gist options
  • Save dotemacs/126108 to your computer and use it in GitHub Desktop.
Save dotemacs/126108 to your computer and use it in GitHub Desktop.
(defmacro safe-wrap (fn &rest clean-up)
`(unwind-protect
(let (retval)
(condition-case ex
(setq retval (progn ,fn))
('error
(message (format "Caught exception: [%s]" ex))
(setq retval (cons 'exception (list ex)))))
retval)
,@clean-up))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment