diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-07-24 17:52:50 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-07-24 17:52:50 +0000 |
| commit | 8fd5b3ed67d91937516d855bd6f225052aa88f2a (patch) | |
| tree | 5f14c30cb79692b6d35e612ed97feb79f62a155d /contrib/pgcrypto | |
| parent | f0c5384d4a21d85198f86281f61d5754bfdca7a5 (diff) | |
| download | postgresql-8fd5b3ed67d91937516d855bd6f225052aa88f2a.tar.gz | |
Error message editing in contrib (mostly by Joe Conway --- thanks Joe!)
Diffstat (limited to 'contrib/pgcrypto')
| -rw-r--r-- | contrib/pgcrypto/mhash.c | 17 | ||||
| -rw-r--r-- | contrib/pgcrypto/pgcrypto.c | 38 |
2 files changed, 41 insertions, 14 deletions
diff --git a/contrib/pgcrypto/mhash.c b/contrib/pgcrypto/mhash.c index d0be0a62d5..57f6516791 100644 --- a/contrib/pgcrypto/mhash.c +++ b/contrib/pgcrypto/mhash.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mhash.c,v 1.7 2001/11/20 18:54:07 momjian Exp $ + * $Id: mhash.c,v 1.8 2003/07/24 17:52:33 tgl Exp $ */ #include <postgres.h> @@ -143,7 +143,10 @@ cipher_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) err = mcrypt_generic_init(ctx, (char *) key, klen, (char *) iv); if (err < 0) - elog(ERROR, "mcrypt_generic_init error: %s", mcrypt_strerror(err)); + ereport(ERROR, + (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + errmsg("mcrypt_generic_init error"), + errdetail("%s", mcrypt_strerror(err)))); c->pstat = 1; return 0; @@ -159,7 +162,10 @@ cipher_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) err = mcrypt_generic(ctx, res, dlen); if (err < 0) - elog(ERROR, "mcrypt_generic error: %s", mcrypt_strerror(err)); + ereport(ERROR, + (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + errmsg("mcrypt_generic error"), + errdetail("%s", mcrypt_strerror(err)))); return 0; } @@ -173,7 +179,10 @@ cipher_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) err = mdecrypt_generic(ctx, res, dlen); if (err < 0) - elog(ERROR, "mdecrypt_generic error: %s", mcrypt_strerror(err)); + ereport(ERROR, + (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + errmsg("mdecrypt_generic error"), + errdetail("%s", mcrypt_strerror(err)))); return 0; } diff --git a/contrib/pgcrypto/pgcrypto.c b/contrib/pgcrypto/pgcrypto.c index d3dc36dc9a..de0d426f46 100644 --- a/contrib/pgcrypto/pgcrypto.c +++ b/contrib/pgcrypto/pgcrypto.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pgcrypto.c,v 1.12 2001/12/30 23:09:41 tgl Exp $ + * $Id: pgcrypto.c,v 1.13 2003/07/24 17:52:33 tgl Exp $ */ #include <postgres.h> @@ -202,7 +202,9 @@ pg_gen_salt(PG_FUNCTION_ARGS) buf[len] = 0; len = px_gen_salt(buf, buf, 0); if (len == 0) - elog(ERROR, "No such crypt algorithm"); + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("no such crypt algorithm"))); res = (text *) palloc(len + VARHDRSZ); VARATT_SIZEP(res) = len + VARHDRSZ; @@ -237,7 +239,9 @@ pg_gen_salt_rounds(PG_FUNCTION_ARGS) buf[len] = 0; len = px_gen_salt(buf, buf, rounds); if (len == 0) - elog(ERROR, "No such crypt algorithm or bad number of rounds"); + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("no such crypt algorithm or bad number of rounds"))); res = (text *) palloc(len + VARHDRSZ); VARATT_SIZEP(res) = len + VARHDRSZ; @@ -292,7 +296,9 @@ pg_crypt(PG_FUNCTION_ARGS) pfree(buf1); if (cres == NULL) - elog(ERROR, "crypt(3) returned NULL"); + ereport(ERROR, + (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + errmsg("crypt(3) returned NULL"))); clen = strlen(cres); @@ -349,7 +355,9 @@ pg_encrypt(PG_FUNCTION_ARGS) if (err) { pfree(res); - elog(ERROR, "encrypt error: %d", err); + ereport(ERROR, + (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + errmsg("encrypt error: %d", err))); } VARATT_SIZEP(res) = VARHDRSZ + rlen; @@ -393,7 +401,9 @@ pg_decrypt(PG_FUNCTION_ARGS) px_combo_free(c); if (err) - elog(ERROR, "decrypt error: %d", err); + ereport(ERROR, + (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + errmsg("decrypt error: %d", err))); VARATT_SIZEP(res) = VARHDRSZ + rlen; @@ -446,7 +456,9 @@ pg_encrypt_iv(PG_FUNCTION_ARGS) px_combo_free(c); if (err) - elog(ERROR, "encrypt_iv error: %d", err); + ereport(ERROR, + (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + errmsg("encrypt_iv error: %d", err))); VARATT_SIZEP(res) = VARHDRSZ + rlen; @@ -500,7 +512,9 @@ pg_decrypt_iv(PG_FUNCTION_ARGS) px_combo_free(c); if (err) - elog(ERROR, "decrypt_iv error: %d", err); + ereport(ERROR, + (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION), + errmsg("decrypt_iv error: %d", err))); VARATT_SIZEP(res) = VARHDRSZ + rlen; @@ -551,7 +565,9 @@ find_provider(text *name, { if (silent) return NULL; - elog(ERROR, "%s type does not exist (name too long)", desc); + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("%s type does not exist (name too long)", desc))); } p = VARDATA(name); @@ -562,7 +578,9 @@ find_provider(text *name, err = provider_lookup(buf, &res); if (err && !silent) - elog(ERROR, "%s type does not exist: '%s'", desc, buf); + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("%s type does not exist: \"%s\"", desc, buf))); return err ? NULL : res; } |
