Proposed patch to sql-reader-open to provide better error reporting
Alan Shields <[email protected]>
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello all, As best I can manage, here's a patch that gives a mite bit more information when the sql reader doesn't like some input. I'd been having trouble tracking things down for a little while, thought some more detailed error handling would be nice. --- /usr/share/common-lisp/source/clsql/sql/syntax.lisp 2004-09-15 11:45:22.000000000 -0500 +++ sql/syntax.lisp 2005-04-11 19:39:30.000000000 -0500 @@ -88,13 +88,18 @@ (defun sql-reader-open (stream char) (declare (ignore char)) (let ((sqllist (read-delimited-list #\] stream t))) - (cond ((string= (write-to-string (car sqllist)) "||") - (cons (sql-operator 'concat-op) (cdr sqllist))) - ((and (= (length sqllist) 1) (eql (car sqllist) '*)) - (apply #'generate-sql-reference sqllist)) - ((sql-operator (car sqllist)) - (cons (sql-operator (car sqllist)) (cdr sqllist))) - (t (apply #'generate-sql-reference sqllist))))) + (handler-case + (cond ((string= (write-to-string (car sqllist)) "||") + (cons (sql-operator 'concat-op) (cdr sqllist))) + ((and (= (length sqllist) 1) (eql (car sqllist) '*)) + (apply #'generate-sql-reference sqllist)) + ((sql-operator (car sqllist)) + (cons (sql-operator (car sqllist)) (cdr sqllist))) + (t (apply #'generate-sql-reference sqllist))) + (sql-user-error (c) + (error 'sql-user-error + :message (format nil "Error ~A occured while attempting to parse '~A' at file position ~A" + (sql-user-error-message c) sqllist (file-position stream))))))) (defun disable-sql-close-syntax () "Internal function that disables the close syntax when leaving