Improve error reporting of EUDC plist functions
* lisp/net/eudc.el (eudc--plist-member): Signal a more informative wrong-type-argument instead of a generic error (bug#58531#19, bug#58720). * test/lisp/net/eudc-tests.el (eudc--plist-member) (eudc-plist-member, eudc-plist-get, eudc-lax-plist-get): Update tests accordingly.
This commit is contained in:
parent
e25a108b09
commit
9db7b11cf7
2 changed files with 14 additions and 15 deletions
|
@ -108,9 +108,8 @@
|
|||
|
||||
(defun eudc--plist-member (plist prop &optional predicate)
|
||||
"Like `plist-member', but signal on invalid PLIST."
|
||||
;; Could also use `plistp', but that would change the error.
|
||||
(or (zerop (% (length plist) 2))
|
||||
(error "Malformed plist"))
|
||||
(or (plistp plist)
|
||||
(signal 'wrong-type-argument `(plistp ,plist)))
|
||||
(plist-member plist prop predicate))
|
||||
|
||||
(defun eudc-plist-member (plist prop)
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
(dolist (obj '(a (a . a) (a a . a)))
|
||||
(should-error (eudc--plist-member obj nil) :type 'wrong-type-argument))
|
||||
(dolist (plist '((nil) (a) (a a a)))
|
||||
(dolist (key '(nil a))
|
||||
(should (equal (should-error (eudc--plist-member plist key))
|
||||
'(error "Malformed plist")))))
|
||||
(let ((err `(wrong-type-argument plistp ,(copy-sequence plist))))
|
||||
(dolist (key '(nil a))
|
||||
(should (equal err (should-error (eudc--plist-member plist key)))))))
|
||||
(let ((-nil (string ?n ?i ?l))
|
||||
(-a (string ?a)))
|
||||
(should-not (eudc--plist-member () nil))
|
||||
|
@ -56,9 +56,9 @@
|
|||
(dolist (obj '(a (a . a) (a a . a)))
|
||||
(should-error (eudc-plist-member obj nil) :type 'wrong-type-argument))
|
||||
(dolist (plist '((nil) (a) (a a a)))
|
||||
(dolist (key '(nil a))
|
||||
(should (equal (should-error (eudc-plist-member plist key))
|
||||
'(error "Malformed plist")))))
|
||||
(let ((err `(wrong-type-argument plistp ,(copy-sequence plist))))
|
||||
(dolist (key '(nil a))
|
||||
(should (equal err (should-error (eudc-plist-member plist key)))))))
|
||||
(let ((-nil (string ?n ?i ?l))
|
||||
(-a (string ?a)))
|
||||
(should-not (eudc-plist-member () nil))
|
||||
|
@ -86,9 +86,9 @@
|
|||
(dolist (obj '(a (a . a) (a a . a)))
|
||||
(should-error (eudc-plist-get obj nil) :type 'wrong-type-argument))
|
||||
(dolist (plist '((nil) (a) (a a a)))
|
||||
(dolist (key '(nil a))
|
||||
(should (equal (should-error (eudc-plist-get plist key))
|
||||
'(error "Malformed plist")))))
|
||||
(let ((err `(wrong-type-argument plistp ,(copy-sequence plist))))
|
||||
(dolist (key '(nil a))
|
||||
(should (equal err (should-error (eudc-plist-get plist key)))))))
|
||||
(let ((-nil (string ?n ?i ?l))
|
||||
(-a (string ?a)))
|
||||
(should-not (eudc-plist-get () nil))
|
||||
|
@ -120,9 +120,9 @@
|
|||
(dolist (obj '(a (a . a) (a a . a)))
|
||||
(should-error (eudc-lax-plist-get obj nil) :type 'wrong-type-argument))
|
||||
(dolist (plist '((nil) (a) (a a a)))
|
||||
(dolist (key '(nil a))
|
||||
(should (equal (should-error (eudc-lax-plist-get plist key))
|
||||
'(error "Malformed plist")))))
|
||||
(let ((err `(wrong-type-argument plistp ,(copy-sequence plist))))
|
||||
(dolist (key '(nil a))
|
||||
(should (equal err (should-error (eudc-lax-plist-get plist key)))))))
|
||||
(let ((-nil (string ?n ?i ?l))
|
||||
(-a (string ?a)))
|
||||
(should-not (eudc-lax-plist-get () nil))
|
||||
|
|
Loading…
Add table
Reference in a new issue