aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-06-20 08:33:23 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2008-06-20 08:33:23 +0000
commit2ade1343e35ae3c9a3e63ddb9608b1e1fade4a49 (patch)
tree990589b6700969fd9b712d40703bc606393d97c5
parentbde62e32483d9211ca94559081512160139f9ebf (diff)
downloadgamma-2ade1343e35ae3c9a3e63ddb9608b1e1fade4a49.tar.gz
gamma-2ade1343e35ae3c9a3e63ddb9608b1e1fade4a49.tar.bz2
(sql-catch-failure, sql-ignore-failure): New syntax.
-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.