Merge pull request #39 from plexus/arne/better-parse-error

Provide a better error when .emacs-profiles.el is invalid
This commit is contained in:
Arne Brasseur 2022-05-03 15:05:05 +02:00 committed by GitHub
commit 8683883211
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -91,7 +91,7 @@
(insert-file-contents chemacs-default-profile-path)
(goto-char (point-min))
;; (buffer-string))
(symbol-name (read (current-buffer)) ))
(symbol-name (read (current-buffer))))
"default"))
@ -107,12 +107,15 @@
(if (and chemacs--with-profile-value
(listp chemacs--with-profile-value))
chemacs--with-profile-value
(let ((profiles
(with-temp-buffer
(insert-file-contents chemacs-profiles-path)
(goto-char (point-min))
(read (current-buffer)))))
(cdr (assoc chemacs-profile-name profiles)))))
(let ((profiles
(with-temp-buffer
(insert-file-contents chemacs-profiles-path)
(goto-char (point-min))
(condition-case err
(read (current-buffer))
(error
(error "Failed to parse %s: %s" chemacs-profiles-path (error-message-string err)))))))
(cdr (assoc chemacs-profile-name profiles)))))
(unless chemacs-profile
(error "No profile `%s' in %s" chemacs-profile-name chemacs-profiles-path))