Changeset error-handling,3
- Timestamp:
- 11/28/2007 05:54:57 PM (19 years ago)
- branch-nick:
- error-handling
- revision id:
- dsowen@fugue88.ws-20071128175457-jt34hu6qm16hk2h4
- Location:
- error-handling/src/odbc
- Files:
-
- 2 edited
-
odbc-functions.lisp (modified) (2 diffs)
-
plain-odbc-package.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
error-handling/src/odbc/odbc-functions.lisp
r1 r3 110 110 )) 111 111 112 113 (defun print-odbc-error (condition stream) 114 (with-slots (message code) condition 115 (format stream "[ODBC error] ~a; state: ~a" message code))) 116 117 (define-condition odbc-error (error) 118 ((message :initarg :message :reader error-message) 119 (code :initarg :code :reader error-code)) 120 (:report print-odbc-error)) 121 122 (define-condition odbc-foreign-key-error (odbc-error) ()) 123 124 (defun read-and-throw-error (henv hdbc hstmt) 125 (multiple-value-bind (error-message sql-state) 126 (handle-error (or henv (cffi:null-pointer)) 127 (or hdbc (cffi:null-pointer)) 128 (or hstmt (cffi:null-pointer))) 129 (let ((type (cdr (assoc sql-state '(("23503" . odbc-foreign-key-error)) 130 :test #'string=)))) 131 (error (if type type 'odbc-error) 132 :message error-message 133 :code sql-state)))) 112 134 113 135 ;;; rav: … … 154 176 (error "[ODBC error] Still executing")) 155 177 (#.$SQL_ERROR 156 (multiple-value-bind (error-message sql-state) 157 (handle-error (or ,henv (cffi:null-pointer)) 158 (or ,hdbc (cffi:null-pointer)) 159 (or ,hstmt (cffi:null-pointer))) 160 (error "[ODBC error] ~a; state: ~a" error-message sql-state))) 178 (read-and-throw-error ,henv ,hdbc ,hstmt)) 161 179 (otherwise 162 180 (progn ,result-code ,@body)) -
error-handling/src/odbc/plain-odbc-package.lisp
r1 r3 12 12 "COMMON-LISP" #+mcl "CCL" #+cormanlisp "WIN32" "CFFI") 13 13 (:export 14 "ODBC-ERROR" 15 "ODBC-FOREIGN-KEY-ERROR" 16 14 17 "EXEC-QUERY" 15 18 "EXEC-UPDATE"
Note: See TracChangeset
for help on using the changeset viewer.
