diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-06-20 08:33:23 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-06-20 08:33:23 +0000 |
commit | 2ade1343e35ae3c9a3e63ddb9608b1e1fade4a49 (patch) | |
tree | 990589b6700969fd9b712d40703bc606393d97c5 | |
parent | bde62e32483d9211ca94559081512160139f9ebf (diff) | |
download | gamma-2ade1343e35ae3c9a3e63ddb9608b1e1fade4a49.tar.gz gamma-2ade1343e35ae3c9a3e63ddb9608b1e1fade4a49.tar.bz2 |
(sql-catch-failure, sql-ignore-failure): New syntax.
-rw-r--r-- | src/sql.sci | 27 |
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 |