diff --git a/src/main.lisp b/src/main.lisp index 96e21fa..33137da 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -122,13 +122,15 @@ etc.) happened" (shared-init) (db-utils:with-ready-database (:connect nil) (complete:initialize-complete-username-cache) - (handler-case - (or (ignore-errors (modules:load-sys-module +starting-init-file+)) - (modules:load-module +starting-init-file+)) - (error (e) + (let ((system-config-file-found-p (modules:load-sys-module +starting-init-file+ + :not-found-signal-error nil))) + (multiple-value-bind (home-config-file-found-p error-message) + (modules:load-module +starting-init-file+ :not-found-signal-error nil) + (when (not (or system-config-file-found-p + home-config-file-found-p)) (croatoan:end-screen) - (format *error-output* "~a~%" e) - (os-utils:exit-program 1))) + (format *error-output* "~a~%" error-message) + (os-utils:exit-program 1)))) ;; init main window for first... (main-window:init) (keybindings-window:init) diff --git a/src/modules.lisp b/src/modules.lisp index 28a4318..9824286 100644 --- a/src/modules.lisp +++ b/src/modules.lisp @@ -17,11 +17,13 @@ (in-package :modules) -(defun load-sys-module (path) - (let ((file (get-sys-config-file path))) +(defun load-sys-module (path &key (not-found-signal-error t)) + (when-let ((file (if not-found-signal-error + (get-sys-config-file path) + (ignore-errors (get-sys-config-file path))))) (load file :verbose nil :print nil))) -(defun load-module (path) +(defun load-module (path &key (not-found-signal-error t)) (flet ((%load (file) (load file :verbose nil :print nil))) (let ((config-file (conditions:with-default-on-error (nil) @@ -34,10 +36,13 @@ (data-file (%load data-file)) (t - (error (format nil - (_ "Unrecoverable error: file ~a not found in any of the directory ~a ~a ~a ~a") - path - +sys-data-dir+ - +sys-conf-dir+ - (home-datadir) - (home-confdir)))))))) + (let ((error-message (format nil + (_ "Unrecoverable error: file ~a not found in any of the directory ~a ~a ~a ~a") + path + +sys-data-dir+ + +sys-conf-dir+ + (home-datadir) + (home-confdir)))) + (if not-found-signal-error + (error error-message) + (values nil error-message))))))))