Improve warning and error messages
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read, (eieio-persistent-validate/fix-slot-value): Indicate exactly what went wrong.
This commit is contained in:
parent
7612dd14b6
commit
daa9e853bd
1 changed files with 12 additions and 8 deletions
|
@ -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
|
`eieio-persistent-read' to load in subclasses of class instead of
|
||||||
being pedantic."
|
being pedantic."
|
||||||
(unless class
|
(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))
|
(when class (cl-check-type class class))
|
||||||
(let ((ret nil)
|
(let ((ret nil)
|
||||||
(buffstr nil))
|
(buffstr nil))
|
||||||
|
@ -234,13 +234,16 @@ being pedantic."
|
||||||
;; the current buffer will work.
|
;; the current buffer will work.
|
||||||
(setq ret (read buffstr))
|
(setq ret (read buffstr))
|
||||||
(when (not (child-of-class-p (car ret) 'eieio-persistent))
|
(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
|
(when (and class
|
||||||
(not (or (eq (car ret) class ) ; same class
|
(not (or (eq (car ret) class) ; same class
|
||||||
(and allow-subclass
|
(and allow-subclass ; subclass
|
||||||
(child-of-class-p (car ret) class)) ; subclasses
|
(child-of-class-p (car ret) class)))))
|
||||||
)))
|
(error
|
||||||
(error "Corrupt object on disk: Invalid saved class"))
|
"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))
|
(setq ret (eieio-persistent-convert-list-to-object ret))
|
||||||
(oset ret file filename))
|
(oset ret file filename))
|
||||||
(kill-buffer " *tmp eieio read*"))
|
(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?
|
;; We have a predicate, but it doesn't satisfy the predicate?
|
||||||
(dolist (PV (cdr proposed-value))
|
(dolist (PV (cdr proposed-value))
|
||||||
(unless (child-of-class-p (car PV) (car classtype))
|
(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
|
;; We have a list of objects here. Lets load them
|
||||||
;; in.
|
;; in.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue