Function: apheleia--with-on-error

apheleia--with-on-error is a macro defined in apheleia.el.

Signature

(apheleia--with-on-error ON-ERROR &rest BODY)

Documentation

Call ON-ERROR with an error if BODY throws an error.

Return the error in that case, instead of throwing it. If ON-ERROR is nil, instead act just like progn.

Source Code

;; Defined in /nix/store/lwcwryzabcmvjcwwzzs65jrwf7p7d7cs-emacs-packages-deps/share/emacs/site-lisp/elpa/apheleia-20260915.1628/apheleia.el
(defmacro apheleia--with-on-error (on-error &rest body)
  "Call ON-ERROR with an error if BODY throws an error.
Return the error in that case, instead of throwing it. If
ON-ERROR is nil, instead act just like `progn'."
  (declare (indent 1))
  (let ((err-sym (make-symbol "err"))
        (on-error-sym (make-symbol "on-error")))
    `(let ((,on-error-sym ,on-error))
       (if ,on-error-sym
           (condition-case-unless-debug ,err-sym
               (progn ,@body)
             (error (funcall ,on-error-sym ,err-sym)))
         (progn ,@body)))))