-(define-condition clsql-generic-error (clsql-error)
- ((message :initarg :message
- :reader clsql-generic-error-message))
- (:report (lambda (c stream)
- (format stream (clsql-generic-error-message c)))))
-
-(define-condition clsql-invalid-spec-error (clsql-error)
- ((connection-spec :initarg :connection-spec
- :reader clsql-invalid-spec-error-connection-spec)
- (database-type :initarg :database-type
- :reader clsql-invalid-spec-error-database-type)
- (template :initarg :template
- :reader clsql-invalid-spec-error-template))
- (:report (lambda (c stream)
- (format stream "The connection specification ~A~%is invalid for database type ~A.~%The connection specification must conform to ~A"
- (clsql-invalid-spec-error-connection-spec c)
- (clsql-invalid-spec-error-database-type c)
- (clsql-invalid-spec-error-template c)))))
-
-(defmacro check-connection-spec (connection-spec database-type template)
- "Check the connection specification against the provided template,
-and signal an clsql-invalid-spec-error if they don't match."
- `(handler-case
- (destructuring-bind ,template ,connection-spec
- (declare (ignore ,@(remove '&optional template)))
- t)
- (error () (error 'clsql-invalid-spec-error
- :connection-spec ,connection-spec
- :database-type ,database-type
- :template (quote ,template)))))
-
-(define-condition clsql-access-error (clsql-error)
- ((database-type :initarg :database-type
- :reader clsql-access-error-database-type)
- (connection-spec :initarg :connection-spec
- :reader clsql-access-error-connection-spec)
- (error :initarg :error :reader clsql-access-error-error))
+(define-condition sql-database-error (sql-error)
+ ((error-id :initarg :error-id
+ :initform nil
+ :reader sql-error-error-id)
+ (secondary-error-id :initarg :secondary-error-id
+ :initform nil
+ :reader sql-error-secondary-error-id)
+ (database-message :initarg :message
+ :initform nil
+ :reader sql-error-database-message)
+ (database :initarg :database
+ :initform nil
+ :reader sql-error-database))