Mercurial > hg > xemacs-beta
comparison lisp/specifier.el @ 5244:04811a268716
Be clearer in our error messages, #'canonicalize-inst-pair, #'canonicalize-spec
lisp/ChangeLog addition:
2010-08-15 Aidan Kehoe <kehoea@parhasard.net>
* specifier.el (canonicalize-inst-pair, canonicalize-spec):
If a specifier tag set is correct, but an instantiator is not in
an accepted format, don't error with the message "Invalid
specifier tag set".
Also, when we error, use error-symbols, for better structured
error handling and more ease when testing.
tests/ChangeLog addition:
2010-08-15 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
(not, not, invalid-argument, invalid-argument):
Check that error messages from the image specifier instantiator
code are clearer than they used to be.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 15 Aug 2010 15:42:45 +0100 |
parents | 18c0b5909d16 |
children | 668c73e222fd |
comparison
equal
deleted
inserted
replaced
5243:808131ba4a57 | 5244:04811a268716 |
---|---|
103 ;; not an inst-pair | 103 ;; not an inst-pair |
104 (if noerror t | 104 (if noerror t |
105 ;; this will signal an appropriate error. | 105 ;; this will signal an appropriate error. |
106 (check-valid-instantiator inst-pair specifier-type))) | 106 (check-valid-instantiator inst-pair specifier-type))) |
107 | 107 |
108 ((and (valid-specifier-tag-p (car inst-pair)) | 108 ((not (valid-instantiator-p (cdr inst-pair) specifier-type)) |
109 (valid-instantiator-p (cdr inst-pair) specifier-type)) | 109 (if noerror |
110 t | |
111 (check-valid-instantiator (cdr inst-pair) specifier-type))) | |
112 | |
113 ((valid-specifier-tag-p (car inst-pair)) | |
110 ;; case (b) | 114 ;; case (b) |
111 (cons (list (car inst-pair)) (cdr inst-pair))) | 115 (cons (list (car inst-pair)) (cdr inst-pair))) |
112 | 116 |
113 ((and (valid-specifier-tag-set-p (car inst-pair)) | 117 ((valid-specifier-tag-set-p (car inst-pair)) |
114 (valid-instantiator-p (cdr inst-pair) specifier-type)) | |
115 ;; case (c) | 118 ;; case (c) |
116 inst-pair) | 119 inst-pair) |
117 | 120 |
118 (t | 121 (t |
119 (if noerror t | 122 (if noerror t |
120 (signal 'error (list "Invalid specifier tag set" | 123 (error 'invalid-argument "Invalid specifier tag set" |
121 (car inst-pair))))))) | 124 (car inst-pair)))))) |
122 | 125 |
123 (defun canonicalize-inst-list (inst-list specifier-type &optional noerror) | 126 (defun canonicalize-inst-list (inst-list specifier-type &optional noerror) |
124 "Canonicalize the given INST-LIST (a list of inst-pairs). | 127 "Canonicalize the given INST-LIST (a list of inst-pairs). |
125 | 128 |
126 SPECIFIER-TYPE specifies the type of specifier that this INST-LIST | 129 SPECIFIER-TYPE specifies the type of specifier that this INST-LIST |
197 ;; this will signal an appropriate error. | 200 ;; this will signal an appropriate error. |
198 (check-valid-instantiator spec specifier-type)) | 201 (check-valid-instantiator spec specifier-type)) |
199 | 202 |
200 (if (not (valid-specifier-locale-p (car spec))) | 203 (if (not (valid-specifier-locale-p (car spec))) |
201 ;; invalid locale. | 204 ;; invalid locale. |
202 (if noerror t | 205 (if noerror |
203 (signal 'error (list "Invalid specifier locale" (car spec)))) | 206 t |
204 | 207 (if (consp (car spec)) |
208 ;; If it's a cons, they're probably not passing a locale | |
209 (error 'invalid-argument | |
210 "Not a valid instantiator list" spec) | |
211 (error 'invalid-argument | |
212 "Invalid specifier locale" (car spec)))) | |
205 ;; case (b) | 213 ;; case (b) |
206 (let ((result (canonicalize-inst-list (cdr spec) specifier-type | 214 (let ((result (canonicalize-inst-list (cdr spec) specifier-type |
207 noerror))) | 215 noerror))) |
208 (if (eq result t) | 216 (if (eq result t) |
209 ;; at this point, we know we're noerror because | 217 ;; at this point, we know we're noerror because |