git.iko.soy/typeable/postgresql-simple
on master help sign in
Improve exception message from fold functions
762005fLeon P Smith
src/Database/PostgreSQL/Simple.hs+10−2
@@ -435,8 +435,16 @@ finishFold conn c q a_ f = loop a_
435 Right r -> f a r)
435 Right r -> f a r)
436 a [0..nrows-1]
436 a [0..nrows-1]
437 loop a'
437 loop a'
438− _ -> clear c >> fail "FIXME: finishFold not PQ.TuplesOk"
438+ _ -> do
439−
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 ]}
440 clear c = do
448 clear c = do
441 mres <- PQ.getResult c
449 mres <- PQ.getResult c
442 case mres of
450 case mres of