   (interactive "P")
   (when IS-WINDOWS
     (user-error "Cannot reload envvar file from within Emacs on Windows, run it from cmd.exe"))
-  (doom--compile
-    (format "%s -ic '%s env%s'"
-            (string-trim
-             (shell-command-to-string
-             (format "getent passwd %S | cut -d: -f7"
-                     (user-login-name))))
-            doom-bin (if arg " -c" ""))
-    :on-success
-    (let ((doom-reloading-p t))
-      (unless arg
-        (doom-load-envvars-file doom-env-file)))
-    :on-failure
+  (doom--if-compile
+      (format "%s -ic '%s env%s'"
+              (string-trim
+               (shell-command-to-string
+                (format "getent passwd %S | cut -d: -f7"
+                        (user-login-name))))
+              doom-bin (if arg " -c" ""))
+      (let ((doom-reloading-p t))
+        (unless arg
+          (doom-load-envvars-file doom-env-file)))
     (error "Failed to generate env file")))
 
 ;;;###autoload
 (defun doom/upgrade ()
   "Run 'doom upgrade' then prompt to restart Emacs."
   (interactive)
-  (doom--compile (format "%s upgrade" doom-bin)
-    :on-success
-    (when (y-or-n-p "You must restart Emacs for the upgrade to take effect.\n\nRestart Emacs?")
-      (doom/restart-and-restore))))
+  (doom--if-compile (format "%s upgrade" doom-bin)
+      (when (y-or-n-p "You must restart Emacs for the upgrade to take effect.\n\nRestart Emacs?")
+        (doom/restart-and-restore))))

;;
;;; Managements

(cl-defmacro doom--compile (command &key on-success on-failure)
  (declare (indent defun))
  `(with-current-buffer (compile ,command)
     (add-hook
      'compilation-finish-functions

  ;; In case doom/reload is run before incrementally loaded packages are loaded,
  ;; which could cause odd load order issues.
  (mapc #'require (cdr doom-incremental-packages))
  (doom--if-compile (format "%s sync -e" doom-bin)
      (let ((doom-reloading-p t))
        (doom-initialize 'force)
        (with-demoted-errors "PRIVATE CONFIG ERROR: %s"
          (general-auto-unbind-keys)
          (unwind-protect
              (doom-initialize-modules 'force)
            (general-auto-unbind-keys t)))
        (run-hook-wrapped 'doom-reload-hook #'doom-try-hook)
        (print! (success "Config successfully reloaded!")))
    (user-error "Failed to reload your config")))

;;;###autoload
