X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Fconditions.lisp;h=aee96d82c1533aacfb996d01e1fb1f3af2062f82;hb=62547c6f6925d82c6fbc46801700b9256cf2c253;hp=6270f915ac945340538198ee1fccc6068a8f7d76;hpb=8c6c643e3debe875bd14408cc3129d8148dfd125;p=clsql.git diff --git a/sql/conditions.lisp b/sql/conditions.lisp index 6270f91..aee96d8 100644 --- a/sql/conditions.lisp +++ b/sql/conditions.lisp @@ -25,7 +25,10 @@ set to :error to signal an error or :ignore/nil to silently ignore the warning." (define-condition sql-condition () ()) -(define-condition sql-database-error (simple-error sql-condition) +(define-condition sql-error (simple-error) + ()) + +(define-condition sql-database-error (sql-error) ((error-id :initarg :error-id :initform nil :reader sql-error-error-id) @@ -39,7 +42,7 @@ set to :error to signal an error or :ignore/nil to silently ignore the warning." :initform nil :reader sql-error-database)) (:report (lambda (c stream) - (format stream "A database error occurred: ~A / ~A~% ~A" + (format stream "A database error occurred~A: ~A / ~A~% ~A" (if (sql-error-database c) (format nil " on database ~A" (sql-error-database c)) "") @@ -74,7 +77,7 @@ set to :error to signal an error or :ignore/nil to silently ignore the warning." (define-condition sql-temporary-error (sql-database-error) ()) -(define-condition sql-user-error (simple-error sql-condition) +(define-condition sql-user-error (sql-error) ((message :initarg :message :initform "Unspecified error" :reader sql-user-error-message)) @@ -86,14 +89,14 @@ set to :error to signal an error or :ignore/nil to silently ignore the warning." ;; Signal conditions (defun signal-closed-database-error (database) - (cerror 'sql-connection-error - :message - (format nil "Trying to perform operation on closed database ~A." - database))) + (error 'sql-connection-error + :database database + :message "Database is closed.")) (defun signal-no-database-error (database) - (error 'sql-database-error - :message "Not a database: ~A." database)) + (error 'sql-database-error + :database database + :message (format nil "~A is not a database." database))) ;;; CLSQL Extensions