git.iko.soy/typeable/postgresql-simple
on master help sign in
Merge pull request #184 from bgamari/master

Copy: Show error message on failure

commit999d70ff24bb8369c7c128443a3476435ae17fd7 authorLeon P Smith <leon.p.smith+github@gmail.com> dateThu 19 May 2016, 13:00 (10 years ago) parent80e2e955ce5d2e
1 file changed+3−1
src/Database/PostgreSQL/Simple/Copy.hs+3−1
src/Database/PostgreSQL/Simple/Copy.hs+3−1
@@ -224,7 +224,9 @@ getCopyCommandTag funcName pqconn = do
224224 consumeResults pqconn
225225 let rowCount = P.string "COPY " *> (P.decimal <* P.endOfInput)
226226 case P.parseOnly rowCount cmdStat of
227− Left _ -> fail errCmdStatusFmt
227+ Left _ -> do mmsg <- PQ.errorMessage pqconn
228+ fail $ errCmdStatusFmt
229+ ++ maybe "" (\msg -> "\nConnection error: "++B.unpack msg) mmsg
228230 Right n -> return $! n
229231 where
230232 errCmdStatus = B.unpack funcName ++ ": failed to fetch command status"