summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Abrahamsen <eric@ericabrahamsen.net>2018-03-10 16:26:38 +0800
committerEric Abrahamsen <eric@ericabrahamsen.net>2018-03-10 16:26:38 +0800
commit5b1253cab52f0fe04e6088db5330f1c88a05dee1 (patch)
tree257fd253522da018fb6dd8bfd4ae23888643d02e
parent6cb8414726aecbded2ba4aa1304052404b94b40d (diff)
downloademacs-fix/eieio-persistent.tar.gz
Improve warning and error messagesfix/eieio-persistent
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read, (eieio-persistent-validate/fix-slot-value): Indicate exactly what went wrong.
-rw-r--r--lisp/emacs-lisp/eieio-base.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index 2794f88f1f0..6408c4cb6ad 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -219,7 +219,7 @@ for CLASS. Optional ALLOW-SUBCLASS says that it is ok for
`eieio-persistent-read' to load in subclasses of class instead of
being pedantic."
(unless class
- (message "Unsafe call to `eieio-persistent-read'."))
+ (warn "`eieio-persistent-read' called without specifying a class"))
(when class (cl-check-type class class))
(let ((ret nil)
(buffstr nil))
@@ -234,13 +234,16 @@ being pedantic."
;; the current buffer will work.
(setq ret (read buffstr))
(when (not (child-of-class-p (car ret) 'eieio-persistent))
- (error "Corrupt object on disk: Unknown saved object"))
+ (error
+ "Invalid object: %s is not a subclass of `eieio-persistent'"
+ (car ret)))
(when (and class
- (not (or (eq (car ret) class ) ; same class
- (and allow-subclass
- (child-of-class-p (car ret) class)) ; subclasses
- )))
- (error "Corrupt object on disk: Invalid saved class"))
+ (not (or (eq (car ret) class) ; same class
+ (and allow-subclass ; subclass
+ (child-of-class-p (car ret) class)))))
+ (error
+ "Invalid object: %s is not an object of class %s nor a subclass"
+ (car ret) class))
(setq ret (eieio-persistent-convert-list-to-object ret))
(oset ret file filename))
(kill-buffer " *tmp eieio read*"))
@@ -332,7 +335,8 @@ Second, any text properties will be stripped from strings."
;; We have a predicate, but it doesn't satisfy the predicate?
(dolist (PV (cdr proposed-value))
(unless (child-of-class-p (car PV) (car classtype))
- (error "Corrupt object on disk")))
+ (error "Invalid object: slot member %s does not match class %s"
+ (car PV) (car classtype))))
;; We have a list of objects here. Lets load them
;; in.