r8926: add database-create database-destroy database-probe
[clsql.git] / base / conditions.lisp
index 7fc778101abfa5bf01aa3f0feef7097f7eae9c4a..d5a918ade3ad10388a10d906cc8d4c0ee04cbd75 100644 (file)
@@ -2,7 +2,7 @@
 ;;;; *************************************************************************
 ;;;; FILE IDENTIFICATION
 ;;;;
-;;;; Name:          conditions.cl
+;;;; Name:          conditions.lisp
 ;;;; Purpose:       Error conditions for high-level SQL interface
 ;;;; Programmers:   Kevin M. Rosenberg based on
 ;;;;                 Original code by Pierre R. Mai 
@@ -10,7 +10,7 @@
 ;;;;
 ;;;; $Id$
 ;;;;
-;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
 ;;;;
 ;;;; CLSQL users are granted the rights to distribute and use this software
@@ -18,8 +18,7 @@
 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
 ;;;; *************************************************************************
 
-(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :clsql-base-sys)
+(in-package #:clsql-base-sys)
 
 ;;; Conditions
 (define-condition clsql-condition ()
@@ -62,21 +61,30 @@ and signal an clsql-invalid-spec-error if they don't match."
                     :database-type ,database-type
                     :template (quote ,template)))))
 
-(define-condition clsql-connect-error (clsql-error)
+(define-condition clsql-access-error (clsql-error)
   ((database-type :initarg :database-type
-                 :reader clsql-connect-error-database-type)
+                 :reader clsql-access-error-database-type)
    (connection-spec :initarg :connection-spec
-                   :reader clsql-connect-error-connection-spec)
-   (errno :initarg :errno :reader clsql-connect-error-errno)
-   (error :initarg :error :reader clsql-connect-error-error))
+                   :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))
   (:report (lambda (c stream)
             (format stream "While trying to connect to database ~A~%  using database-type ~A:~%  Error ~D / ~A~%  has occurred."
                     (database-name-from-spec
-                     (clsql-connect-error-connection-spec c)
-                     (clsql-connect-error-database-type c))
-                    (clsql-connect-error-database-type c)
+                     (clsql-access-error-connection-spec c)
+                     (clsql-access-error-database-type c))
+                    (clsql-access-error-database-type c)
                     (clsql-connect-error-errno c)
-                    (clsql-connect-error-error c)))))
+                    (clsql-access-error-error c)))))
 
 (define-condition clsql-sql-error (clsql-error)
   ((database :initarg :database :reader clsql-sql-error-database)
@@ -157,8 +165,9 @@ and signal an clsql-invalid-spec-error if they don't match."
          'clsql-nodb-error
          :database database))
 
-
-;; for USQL support
+(defun signal-no-database-error ()
+  (cerror "Ignore this error and return nil."
+         'clsql-nodb-error))
 
 (define-condition clsql-type-error (clsql-error clsql-condition)
   ((slotname :initarg :slotname
@@ -179,4 +188,4 @@ and signal an clsql-invalid-spec-error if they don't match."
           :reader clsql-sql-syntax-error-reason))
   (:report (lambda (c stream)
             (format stream "Invalid SQL syntax: ~A"
-                    (clsql-sql-syntax-error-reason c)))))
\ No newline at end of file
+                    (clsql-sql-syntax-error-reason c)))))