Permalink
Browse files

Improve exception message from fold functions

  • Loading branch information...
1 parent e0d3346 commit 762005f548f7857f929f927611edcc4b53278c03 @lpsmith committed Jan 3, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/Database/PostgreSQL/Simple.hs
@@ -435,8 +435,16 @@ finishFold conn c q a_ f = loop a_
Right r -> f a r)
a [0..nrows-1]
loop a'
- _ -> clear c >> fail "FIXME: finishFold not PQ.TuplesOk"
-
+ _ -> do
+ errormsg <- maybe "" id <$> PQ.resultErrorMessage result
+ statusmsg <- PQ.resStatus stat
+ state <- maybe "" id <$> PQ.resultErrorField result PQ.DiagSqlstate
+ clear c
+ throwIO $ SqlError {
+ sqlState = state,
+ sqlNativeError = fromEnum stat,
+ sqlErrorMsg = B.concat [ "fold: ", statusmsg
+ , ": ", errormsg ]}
clear c = do
mres <- PQ.getResult c
case mres of

0 comments on commit 762005f

Please sign in to comment.