Mercurial > urweb
changeset 1916:e2345c438f08
Postgres: print SQLSTATE on DML failure, to help figure out when new special cases should be added
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Wed, 27 Nov 2013 15:42:24 -0500 |
parents | 52e88e139b25 |
children | 398298ca82b9 |
files | src/postgres.sml |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/postgres.sml Wed Nov 27 15:28:55 2013 -0500 +++ b/src/postgres.sml Wed Nov 27 15:42:24 2013 -0500 @@ -768,13 +768,19 @@ string "}", newline, case mode of - Settings.Error => box [string "PQclear(res);", + Settings.Error => box [string "{", + newline, + string "char *sqlstate = uw_strdup(ctx, PQresultErrorField(res, PG_DIAG_SQLSTATE));", + newline, + string "PQclear(res);", newline, string "uw_error(ctx, FATAL, \"", string (ErrorMsg.spanToString loc), - string ": DML failed:\\n%s\\n%s\", ", + string ": DML failed:\\n%s\\n%s: %s\", ", dml, - string ", PQerrorMessage(conn));"] + string ", sqlstate, PQerrorMessage(conn));", + newline, + string "}"] | Settings.None => box [string "uw_set_error_message(ctx, PQerrorMessage(conn));", newline, newline,