@@ -78,15 +78,18 @@ import qualified Data.Text.Lazy as LT
7878-- | Exception thrown if conversion from a SQL value to a Haskell
7979-- value fails.
8080data ResultError = Incompatible { errSQLType :: String
81+ , errSQLField :: String
8182 , errHaskellType :: String
8283 , errMessage :: String }
8384 -- ^ The SQL and Haskell types are not compatible.
8485 | UnexpectedNull { errSQLType :: String
86+ , errSQLField :: String
8587 , errHaskellType :: String
8688 , errMessage :: String }
8789 -- ^ A SQL @NULL@ was encountered when the Haskell
8890 -- type did not permit it.
8991 | ConversionFailed { errSQLType :: String
92+ , errSQLField :: String
9093 , errHaskellType :: String
9194 , errMessage :: String }
9295 -- ^ The SQL value could not be parsed, or could not
@@ -232,12 +235,12 @@ ff :: BuiltinType -> String -> (B8.ByteString -> Either String a)
232235 -> Field -> Maybe B8.ByteString -> Ok a
233236ff pgType hsType parse f mstr
234237 | typeOid f /= builtin2oid pgType
235− = left (Incompatible (B8.unpack (typename f)) hsType "")
238+ = left (Incompatible (B8.unpack (typename f)) (maybe "" B8.unpack (name f)) hsType "")
236239 | Nothing <- mstr
237− = left (UnexpectedNull (B8.unpack (typename f)) hsType "")
240+ = left (UnexpectedNull (B8.unpack (typename f)) (maybe "" B8.unpack (name f)) hsType "")
238241 | Just str <- mstr
239242 = case parse str of
240− Left msg -> left (ConversionFailed (B8.unpack (typename f)) hsType msg)
243+ Left msg -> left (ConversionFailed (B8.unpack (typename f)) (maybe "" B8.unpack (name f)) hsType msg)
241244 Right val -> return val
242245{-# INLINE ff #-}
243246
@@ -300,9 +303,10 @@ doFromField f _ _ _ = returnError UnexpectedNull f ""
300303-- exception value and returns it in a 'Left . SomeException'
301304-- constructor.
302305returnError :: forall a err . (Typeable a, Exception err)
303− => (String -> String -> String -> err)
306+ => (String -> String -> String -> String -> err)
304307 -> Field -> String -> Ok a
305308returnError mkErr f = left . mkErr (B.unpack (typename f))
309+ (maybe "" B.unpack (name f))
306310 (show (typeOf (undefined :: a)))
307311
308312atto :: forall a. (Typeable a)