X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=base%2Fconditions.lisp;h=6b7d971d6cf3df623922b11c06e7aeadeaa87fff;hb=ec9b352b8205e4204a06797f98970b03cf532ab2;hp=81a1226bfe48b02a2fbf1456f4bf3ed210303726;hpb=29c15e4e9cf9cbb5ccfe33c0af59a24d0614bef9;p=clsql.git diff --git a/base/conditions.lisp b/base/conditions.lisp index 81a1226..6b7d971 100644 --- a/base/conditions.lisp +++ b/base/conditions.lisp @@ -18,7 +18,11 @@ ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* -(in-package #:clsql-base-sys) +(in-package #:clsql-base) + +(defvar *backend-warning-behavior* :warn + "Action to perform on warning messages from backend. Default is to :warn. May also be +set to :error to signal an error or :ignore/nil to silently ignore the warning.") ;;; Conditions (define-condition clsql-condition () @@ -94,15 +98,20 @@ and signal an clsql-invalid-spec-error if they don't match." (define-condition clsql-sql-error (clsql-error) ((database :initarg :database :reader clsql-sql-error-database) - (expression :initarg :expression :reader clsql-sql-error-expression) - (errno :initarg :errno :reader clsql-sql-error-errno) - (error :initarg :error :reader clsql-sql-error-error)) + (message :initarg :message :initform nil :reader clsql-sql-error-message) + (expression :initarg :expression :initarg nil :reader clsql-sql-error-expression) + (errno :initarg :errno :initarg nil :reader clsql-sql-error-errno) + (error :initarg :error :initarg nil :reader clsql-sql-error-error)) (:report (lambda (c stream) - (format stream "While accessing database ~A~% with expression ~S:~% Error ~D / ~A~% has occurred." - (clsql-sql-error-database c) - (clsql-sql-error-expression c) - (clsql-sql-error-errno c) - (clsql-sql-error-error c))))) + (if (clsql-sql-error-message c) + (format stream "While accessing database ~A~%, Error~% ~A~% has occurred." + (clsql-sql-error-database c) + (clsql-sql-error-message c)) + (format stream "While accessing database ~A~% with expression ~S:~% Error ~D / ~A~% has occurred." + (clsql-sql-error-database c) + (clsql-sql-error-expression c) + (clsql-sql-error-errno c) + (clsql-sql-error-error c)))))) (define-condition clsql-database-warning (clsql-warning) ((database :initarg :database :reader clsql-database-warning-database) @@ -198,3 +207,4 @@ and signal an clsql-invalid-spec-error if they don't match." (:report (lambda (c stream) (format stream "Invalid SQL syntax: ~A" (clsql-sql-syntax-error-reason c))))) +