* lisp/files.el (require-with-check): Improve error messages.
authorPip Cet <pipcet@protonmail.com>
Thu, 15 Aug 2024 16:28:07 +0000 (16:28 +0000)
committerPip Cet <pipcet@protonmail.com>
Thu, 15 Aug 2024 16:28:07 +0000 (16:28 +0000)
lisp/files.el

index eadb4a9d0b1964481505a7edbe339280d896d15c..6cbb1b5c632e4ce41e3f2a58678cfa45aa5274a2 100644 (file)
@@ -1274,9 +1274,17 @@ NOERROR is equal to `reload'), or otherwise emit a warning."
         (cond
          ((assoc fn load-history) nil)  ;We loaded the right file.
          ((eq noerror 'reload) (load fn nil 'nomessage))
-         (t (funcall (if noerror #'warn #'error)
-                     "Feature `%S' is now provided by a different file %s"
-                     feature fn)))))
+         ((and fn (memq feature features))
+          (funcall (if noerror #'warn #'error)
+                   "Feature `%S' is now provided by a different file %s"
+                   feature fn))
+         (fn
+          (funcall (if noerror #'warn #'error)
+                   "Could not load file %s" fn))
+         (t
+          (funcall (if noerror #'warn #'error)
+                   "Could not locate file %s in load path"
+                   (or filename (symbol-name feature)))))))
     res))
 
 (defun file-remote-p (file &optional identification connected)