diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-07-27 04:53:12 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-07-27 04:53:12 +0000 |
commit | b6a1d25b0aa179c86e0607d4c0c3b647dc5bbb87 (patch) | |
tree | 7881c788c3f659b45eb371c0e40fbaf188051cb0 /src/backend/utils/adt/cash.c | |
parent | 524cfad23f31db70a23fc1fe748c050838d5fad0 (diff) |
Error message editing in utils/adt. Again thanks to Joe Conway for doing
the bulk of the heavy lifting ...
Diffstat (limited to 'src/backend/utils/adt/cash.c')
-rw-r--r-- | src/backend/utils/adt/cash.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 4a4e13117ef..e33aad28d64 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -9,7 +9,7 @@ * workings can be found in the book "Software Solutions in C" by * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.58 2003/05/13 18:03:07 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.59 2003/07/27 04:53:03 tgl Exp $ */ #include "postgres.h" @@ -193,7 +193,9 @@ cash_in(PG_FUNCTION_ARGS) s++; if (*s != '\0') - elog(ERROR, "Bad money external representation %s", str); + ereport(ERROR, + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("invalid input syntax for money: \"%s\"", str))); result = (value * sgn); @@ -290,7 +292,9 @@ cash_out(PG_FUNCTION_ARGS) if (minus) { if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol)))) - elog(ERROR, "Memory allocation failed, can't output cash"); + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("out of memory"))); /* Position code of 0 means use parens */ if (convention == 0) @@ -303,7 +307,9 @@ cash_out(PG_FUNCTION_ARGS) else { if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count))) - elog(ERROR, "Memory allocation failed, can't output cash"); + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("out of memory"))); strcpy(result, buf + count); } @@ -468,7 +474,9 @@ cash_div_flt8(PG_FUNCTION_ARGS) Cash result; if (f == 0.0) - elog(ERROR, "division by zero"); + ereport(ERROR, + (errcode(ERRCODE_DIVISION_BY_ZERO), + errmsg("division by zero"))); result = rint(c / f); PG_RETURN_CASH(result); @@ -518,7 +526,9 @@ cash_div_flt4(PG_FUNCTION_ARGS) Cash result; if (f == 0.0) - elog(ERROR, "division by zero"); + ereport(ERROR, + (errcode(ERRCODE_DIVISION_BY_ZERO), + errmsg("division by zero"))); result = rint(c / f); PG_RETURN_CASH(result); @@ -569,7 +579,9 @@ cash_div_int4(PG_FUNCTION_ARGS) Cash result; if (i == 0) - elog(ERROR, "division by zero"); + ereport(ERROR, + (errcode(ERRCODE_DIVISION_BY_ZERO), + errmsg("division by zero"))); result = rint(c / i); @@ -619,7 +631,9 @@ cash_div_int2(PG_FUNCTION_ARGS) Cash result; if (s == 0) - elog(ERROR, "division by zero"); + ereport(ERROR, + (errcode(ERRCODE_DIVISION_BY_ZERO), + errmsg("division by zero"))); result = rint(c / s); PG_RETURN_CASH(result); |