git.iko.soy/typeable/postgresql-simple
on master help sign in
Improve exception message from fold functions
commit762005f548f7857f929f927611edcc4b53278c03 authorLeon P Smith <leon@melding-monads.com> dateTue 3 Jan 2012, 16:46 (15 years ago) parente0d3346
1 file changed+10−2
src/Database/PostgreSQL/Simple.hs+10−2
src/Database/PostgreSQL/Simple.hs+10−2
@@ -435,8 +435,16 @@ finishFold conn c q a_ f = loop a_
435435 Right r -> f a r)
436436 a [0..nrows-1]
437437 loop a'
438− _ -> clear c >> fail "FIXME: finishFold not PQ.TuplesOk"
439−
438+ _ -> do
439+ errormsg <- maybe "" id <$> PQ.resultErrorMessage result
440+ statusmsg <- PQ.resStatus stat
441+ state <- maybe "" id <$> PQ.resultErrorField result PQ.DiagSqlstate
442+ clear c
443+ throwIO $ SqlError {
444+ sqlState = state,
445+ sqlNativeError = fromEnum stat,
446+ sqlErrorMsg = B.concat [ "fold: ", statusmsg
447+ , ": ", errormsg ]}
440448 clear c = do
441449 mres <- PQ.getResult c
442450 case mres of