aboutsummaryrefslogtreecommitdiff
path: root/src/sql.sci
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql.sci')
-rw-r--r--src/sql.sci27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/sql.sci b/src/sql.sci
index d315f69..dff0abb 100644
--- a/src/sql.sci
+++ b/src/sql.sci
@@ -1,6 +1,6 @@
;;;; -*- scheme -*-
;;;; This file is part of guile-sql.
-;;;; Copyright (C) 2002 Sergey Poznyakoff
+;;;; Copyright (C) 2002, 2008 Sergey Poznyakoff
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
@@ -18,7 +18,9 @@
changequote([,])dnl
-(define-module (gamma sql))
+(define-module (gamma sql)
+ :export-syntax (sql-catch-failure sql-ignore-failure))
+(use-syntax (ice-9 syncase))
(let ((lib-path "LIBDIR/"))
(load-extension (string-append
@@ -27,4 +29,25 @@ changequote([,])dnl
include(BUILDDIR/gsql_lib.inc)
include(BUILDDIR/gsql_conn.inc)
+(define-syntax sql-catch-failure
+ (syntax-rules ()
+ ((sql-catch-failure (handler) expr)
+ (catch 'gsql-error
+ (lambda () expr)
+ (lambda (key err descr)
+ (handler err descr))))
+ ((sql-catch-failure expr)
+ (sql-catch-failure (sql-error-handler) expr))))
+
+
+(define-syntax sql-ignore-failure
+ (syntax-rules ()
+ ((sql-ignore-failure (value) expr)
+ (catch 'gsql-error
+ (lambda () expr)
+ (lambda (key err descr)
+ value)))
+ ((sql-ignore-failure expr)
+ (sql-ignore-failure (#f) expr))))
+
;;;; End of sql.scm

Return to:

Send suggestions and report system problems to the System administrator.