Ignore:
Timestamp:
01/18/2008 12:58:17 AM (18 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
error-handling
revision id:
dsowen@fugue88.ws-20080118005817-3jz82tlxi9e09uk4
Message:
  • Made it very easy to define new ODBC errors.
  • Added several ODBC errors.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • combined/src/odbc/odbc-functions.lisp

    r2.2.2 r2.2.3  
    111111
    112112
    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-not-null-violation (odbc-error) ())
    123 
    124 (define-condition odbc-foreign-key-error (odbc-error) ())
    125 
    126 (define-condition odbc-unique-violation (odbc-error) ())
    127 
    128 (define-condition odbc-check-violation (odbc-error) ())
    129 
    130 (define-condition odbc-insufficient-privilege (odbc-error) ())
    131 
    132 (define-condition odbc-undefined-object (odbc-error) ())
    133 
    134 (defun read-and-throw-error (henv hdbc hstmt)
    135   (multiple-value-bind (error-message sql-state)
    136       (handle-error (or henv (cffi:null-pointer))
    137                     (or hdbc (cffi:null-pointer))
    138                     (or hstmt (cffi:null-pointer)))
    139     (let ((type (cdr (assoc sql-state '(("23502" . odbc-not-null-violation)
    140                                         ("23503" . odbc-foreign-key-error)
    141                                         ("23505" . odbc-unique-violation)
    142                                         ("23514" . odbc-check-violation)
    143                                         ("42501" . odbc-insufficient-privilege)
    144                                         ("42704" . odbc-undefined-object))
    145                             :test #'string=))))
    146       (error (if type type 'odbc-error)
    147              :message error-message
    148              :code sql-state))))
    149113
    150114;;; rav:
Note: See TracChangeset for help on using the changeset viewer.