- (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))
- (:report (lambda (c stream)
- (format stream "While trying to access database ~A~% using database-type ~A:~% Error ~A~% has occurred."
- (database-name-from-spec
- (clsql-access-error-connection-spec c)
- (clsql-access-error-database-type c))
- (clsql-access-error-database-type c)
- (clsql-access-error-error c)))))
-
-(define-condition clsql-connect-error (clsql-access-error)
- ((errno :initarg :errno :reader clsql-connect-error-errno))
+ (format stream "A database error occurred: ~A / ~A~% ~A"
+ (if (sql-error-database c)
+ (format nil " on database ~A" (sql-error-database c))
+ "")
+ (sql-error-error-id c)
+ (sql-error-secondary-error-id c)
+ (sql-error-database-message c)))))
+
+(define-condition sql-connection-error (sql-database-error)
+ ((database-type :initarg :database-type :initform nil
+ :reader sql-error-database-type)
+ (connection-spec :initarg :connection-spec :initform nil
+ :reader sql-error-connection-spec))