Skip to content

Commit 999d70f

Browse files
committed
Merge pull request #184 from bgamari/master
Copy: Show error message on failure
2 parents 80e2e95 + 5ce5d2e commit 999d70f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • src/Database/PostgreSQL/Simple

src/Database/PostgreSQL/Simple/Copy.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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"

0 commit comments

Comments
 (0)