diff options
| author | Eric Abrahamsen | 2018-03-10 16:26:38 +0800 |
|---|---|---|
| committer | Eric Abrahamsen | 2018-03-10 16:26:38 +0800 |
| commit | 5b1253cab52f0fe04e6088db5330f1c88a05dee1 (patch) | |
| tree | 257fd253522da018fb6dd8bfd4ae23888643d02e | |
| parent | 6cb8414726aecbded2ba4aa1304052404b94b40d (diff) | |
| download | emacs-fix/eieio-persistent.tar.gz emacs-fix/eieio-persistent.zip | |
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.el | 20 |
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 | |||
| 219 | `eieio-persistent-read' to load in subclasses of class instead of | 219 | `eieio-persistent-read' to load in subclasses of class instead of |
| 220 | being pedantic." | 220 | being pedantic." |
| 221 | (unless class | 221 | (unless class |
| 222 | (message "Unsafe call to `eieio-persistent-read'.")) | 222 | (warn "`eieio-persistent-read' called without specifying a class")) |
| 223 | (when class (cl-check-type class class)) | 223 | (when class (cl-check-type class class)) |
| 224 | (let ((ret nil) | 224 | (let ((ret nil) |
| 225 | (buffstr nil)) | 225 | (buffstr nil)) |
| @@ -234,13 +234,16 @@ being pedantic." | |||
| 234 | ;; the current buffer will work. | 234 | ;; the current buffer will work. |
| 235 | (setq ret (read buffstr)) | 235 | (setq ret (read buffstr)) |
| 236 | (when (not (child-of-class-p (car ret) 'eieio-persistent)) | 236 | (when (not (child-of-class-p (car ret) 'eieio-persistent)) |
| 237 | (error "Corrupt object on disk: Unknown saved object")) | 237 | (error |
| 238 | "Invalid object: %s is not a subclass of `eieio-persistent'" | ||
| 239 | (car ret))) | ||
| 238 | (when (and class | 240 | (when (and class |
| 239 | (not (or (eq (car ret) class ) ; same class | 241 | (not (or (eq (car ret) class) ; same class |
| 240 | (and allow-subclass | 242 | (and allow-subclass ; subclass |
| 241 | (child-of-class-p (car ret) class)) ; subclasses | 243 | (child-of-class-p (car ret) class))))) |
| 242 | ))) | 244 | (error |
| 243 | (error "Corrupt object on disk: Invalid saved class")) | 245 | "Invalid object: %s is not an object of class %s nor a subclass" |
| 246 | (car ret) class)) | ||
| 244 | (setq ret (eieio-persistent-convert-list-to-object ret)) | 247 | (setq ret (eieio-persistent-convert-list-to-object ret)) |
| 245 | (oset ret file filename)) | 248 | (oset ret file filename)) |
| 246 | (kill-buffer " *tmp eieio read*")) | 249 | (kill-buffer " *tmp eieio read*")) |
| @@ -332,7 +335,8 @@ Second, any text properties will be stripped from strings." | |||
| 332 | ;; We have a predicate, but it doesn't satisfy the predicate? | 335 | ;; We have a predicate, but it doesn't satisfy the predicate? |
| 333 | (dolist (PV (cdr proposed-value)) | 336 | (dolist (PV (cdr proposed-value)) |
| 334 | (unless (child-of-class-p (car PV) (car classtype)) | 337 | (unless (child-of-class-p (car PV) (car classtype)) |
| 335 | (error "Corrupt object on disk"))) | 338 | (error "Invalid object: slot member %s does not match class %s" |
| 339 | (car PV) (car classtype)))) | ||
| 336 | 340 | ||
| 337 | ;; We have a list of objects here. Lets load them | 341 | ;; We have a list of objects here. Lets load them |
| 338 | ;; in. | 342 | ;; in. |