summaryrefslogtreecommitdiffabout
path: root/src/pgsql.c
authorSergey Poznyakoff <gray@gnu.org.ua>2010-03-15 20:07:36 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2010-03-15 20:07:36 (GMT)
commit7c6a94930dae634efd8af6db16578d8317153a9a (patch) (side-by-side diff)
tree2d931e2e4595c88c4f704151dcc2316337d4dfa5 /src/pgsql.c
parent04b9cd97aa9287668ce41e3db7e273324d3136bc (diff)
downloadgamma-7c6a94930dae634efd8af6db16578d8317153a9a.tar.gz
gamma-7c6a94930dae634efd8af6db16578d8317153a9a.tar.bz2
Fix exception generation in (gamma sql)
* src/gsql_conn.c (gsql_error): Rename to gamma_sql_error. Change Scheme name to sql-error. All callers updated. * src/guile-sql.h: Likewise. * src/mysql.c (s_mysql_connect, s_mysql_query): Use scm_error to generate error exceptions. * src/pgsql.c (s_pgsql_connect, s_pgsql_query): Likewise. * src/sql.sci (sql-catch-failure) (sql-ignore-failure): Update. * doc/sql.texi: Update.
Diffstat (limited to 'src/pgsql.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/pgsql.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/pgsql.c b/src/pgsql.c
index 2422551..759795e 100644
--- a/src/pgsql.c
+++ b/src/pgsql.c
@@ -64,17 +64,20 @@ s_pgsql_connect (SCM parmlist, const char *func_name)
pgconn = PQsetdbLogin(hostname, port, NULL, NULL, dbname, user, pass);
if (PQstatus(pgconn) == CONNECTION_BAD) {
- SCM args;
+ SCM args, pmsg;
free(hostname);
free(port);
free(user);
free(pass);
-
- args = scm_list_2(scm_makfrom0str("Cannot connect to the database"),
- scm_makfrom0str(PQerrorMessage(pgconn)));
+
+ pmsg = scm_makfrom0str(PQerrorMessage(pgconn));
+ args = scm_list_1(scm_makfrom0str("Cannot connect to the database"));
PQfinish(pgconn);
- scm_throw(gsql_error, args);
+ scm_error(gamma_sql_error, func_name,
+ "~A",
+ args,
+ scm_list_2(SCM_BOOL_F, pmsg));
}
smob = sql_connect_create("pgsql");
@@ -130,8 +133,10 @@ s_pgsql_query(struct sql_connect *conn, const char *query)
res = PQexec(pgconn, query);
if (!res)
- scm_throw(gsql_error,
- scm_list_2(scm_makfrom0str("Error executing PostgreSQL query"),
+ scm_error(gamma_sql_error, "sql-query",
+ "~A",
+ scm_list_1(scm_makfrom0str("Error executing PostgreSQL query")),
+ scm_list_2(SCM_BOOL_F,
scm_makfrom0str(PQerrorMessage(pgconn))));
stat = PQresultStatus(res);
@@ -147,8 +152,11 @@ s_pgsql_query(struct sql_connect *conn, const char *query)
PQclear(res);
break;
default:
- scm_throw(gsql_error, scm_list_2(scm_makfrom0str("PostgreSQL error"),
- scm_makfrom0str(PQresStatus(stat))));
+ scm_error(gamma_sql_error, "sql-query",
+ "~A",
+ scm_list_1(scm_makfrom0str("PostgreSQL error")),
+ scm_list_2(scm_from_uint(stat),
+ scm_from_locale_string(PQresStatus(stat))));
}
return cell;

Return to:

Send suggestions and report system problems to the System administrator.