aboutsummaryrefslogtreecommitdiff
path: root/src/pgsql.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2005-06-26 10:38:26 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2005-06-26 10:38:26 +0000
commit4987cf3134f116d1881602141ccc5ee7d572b8de (patch)
treea86f7135fd97098f6d98aeeabe0799e20615d91c /src/pgsql.c
parentd47c213bb55adbe961c54242c642c2d1b7c3ec6c (diff)
downloadgamma-4987cf3134f116d1881602141ccc5ee7d572b8de.tar.gz
gamma-4987cf3134f116d1881602141ccc5ee7d572b8de.tar.bz2
Throw gsql-error, instead of misc-error, on failure
Diffstat (limited to 'src/pgsql.c')
-rw-r--r--src/pgsql.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/pgsql.c b/src/pgsql.c
index 8c7699b..44b1fa6 100644
--- a/src/pgsql.c
+++ b/src/pgsql.c
@@ -11,10 +11,9 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301 USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -50,8 +49,12 @@ s_pgsql_connect (char *hostname, int port,
snprintf(buf, sizeof buf, "%d", port);
pgconn = PQsetdbLogin(hostname, buf, NULL, NULL, dbname, user, pass);
- if (PQstatus(pgconn) == CONNECTION_BAD)
- return SCM_BOOL_F;
+ if (PQstatus(pgconn) == CONNECTION_BAD) {
+ SCM args = scm_list_2(scm_makfrom0str("Cannot connect to the database"),
+ scm_makfrom0str(PQerrorMessage(pgconn)));
+ PQfinish(pgconn);
+ scm_throw(gsql_error, args);
+ }
smob = sql_connect_create("pgsql");
conn = (struct sql_connect *)SCM_CDR(smob);
@@ -110,9 +113,9 @@ s_pgsql_query(struct sql_connect *conn, char *query)
res = PQexec(pgconn, query);
if (!res)
- scm_misc_error("s_mgsql_query",
- "pgSQL error: ~S",
- SCM_LIST1(scm_makfrom0str(PQerrorMessage(pgconn))));
+ scm_throw(gsql_error,
+ scm_list_2(scm_makfrom0str("Error executing PostgreSQL query"),
+ scm_makfrom0str(PQerrorMessage(pgconn))));
stat = PQresultStatus(res);
@@ -127,9 +130,8 @@ s_pgsql_query(struct sql_connect *conn, char *query)
PQclear(res);
break;
default:
- scm_misc_error("s_mgsql_query",
- "pgSQL error: ~S",
- SCM_LIST1(scm_makfrom0str(PQresStatus(stat))));
+ scm_throw(gsql_error, scm_list_2(scm_makfrom0str("PostgreSQL error"),
+ scm_makfrom0str(PQresStatus(stat))));
}
return cell;

Return to:

Send suggestions and report system problems to the System administrator.