X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=base%2Fconditions.lisp;h=25d4623605396b0bdbd8b75e39b53f7b9d24e093;hp=d5a918ade3ad10388a10d906cc8d4c0ee04cbd75;hb=9bbed78051e80e6ab76ae47834136035602bbbf1;hpb=c4da3cfcbb955395d8a556e1f89aadad696302b7 diff --git a/base/conditions.lisp b/base/conditions.lisp index d5a918a..25d4623 100644 --- a/base/conditions.lisp +++ b/base/conditions.lisp @@ -18,7 +18,7 @@ ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* -(in-package #:clsql-base-sys) +(in-package #:clsql-base) ;;; Conditions (define-condition clsql-condition () @@ -36,6 +36,12 @@ (define-condition clsql-simple-warning (simple-condition clsql-warning) ()) +(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) @@ -145,12 +151,21 @@ and signal an clsql-invalid-spec-error if they don't match." (format stream "The database ~A has already been closed." (clsql-closed-error-database c))))) -(define-condition clsql-nodb-error (clsql-error) - ((database :initarg :database :reader clsql-nodb-error-database)) +(define-condition clsql-no-database-error (clsql-error) + ((database :initarg :database :reader clsql-no-database-error-database)) (:report (lambda (c stream) - (format stream "No such database ~S is open." - (clsql-nodb-error-database c))))) - + (format stream "~S is not a CLSQL database." + (clsql-no-database-error-database c))))) + +(define-condition clsql-odbc-error (clsql-error) + ((odbc-message :initarg :odbc-message + :reader clsql-odbc-error-message) + (sql-state :initarg :sql-state :initform nil + :reader clsql-odbc-error-sql-state)) + (:report (lambda (c stream) + (format stream "[ODBC error] ~A; state: ~A" + (clsql-odbc-error-message c) + (clsql-odbc-error-sql-state c))))) ;; Signal conditions @@ -160,14 +175,8 @@ and signal an clsql-invalid-spec-error if they don't match." 'clsql-closed-error :database database)) -(defun signal-nodb-error (database) - (cerror "Ignore this error and return nil." - 'clsql-nodb-error - :database database)) - -(defun signal-no-database-error () - (cerror "Ignore this error and return nil." - 'clsql-nodb-error)) +(defun signal-no-database-error (database) + (error 'clsql-no-database-error :database database)) (define-condition clsql-type-error (clsql-error clsql-condition) ((slotname :initarg :slotname