@@ -301,43 +301,50 @@ instance FromField [Char] where
301 fromField f dat = ST.unpack <$> fromField f dat
301 fromField f dat = ST.unpack <$> fromField f dat
303instance FromField UTCTime where
303instance FromField UTCTime where
304− fromField = ff TimestampTZ parseUTCTime
304+ fromField = ff TimestampTZ "UTCTime" parseUTCTime
306instance FromField ZonedTime where
306instance FromField ZonedTime where
307− fromField = ff TimestampTZ parseZonedTime
307+ fromField = ff TimestampTZ "ZonedTime" parseZonedTime
309instance FromField LocalTime where
309instance FromField LocalTime where
310− fromField = ff Timestamp parseLocalTime
310+ fromField = ff Timestamp "LocalTime" parseLocalTime
312instance FromField Day where
312instance FromField Day where
313− fromField = ff Date parseDay
313+ fromField = ff Date "Day" parseDay
315instance FromField TimeOfDay where
315instance FromField TimeOfDay where
316− fromField = ff Time parseTimeOfDay
316+ fromField = ff Time "TimeOfDay" parseTimeOfDay
318instance FromField UTCTimestamp where
318instance FromField UTCTimestamp where
319− fromField = ff TimestampTZ parseUTCTimestamp
319+ fromField = ff TimestampTZ "UTCTimestamp" parseUTCTimestamp
321instance FromField ZonedTimestamp where
321instance FromField ZonedTimestamp where
322− fromField = ff TimestampTZ parseZonedTimestamp
322+ fromField = ff TimestampTZ "ZonedTimestamp" parseZonedTimestamp
324instance FromField LocalTimestamp where
324instance FromField LocalTimestamp where
325− fromField = ff Timestamp parseLocalTimestamp
325+ fromField = ff Timestamp "LocalTimestamp" parseLocalTimestamp
327instance FromField Date where
327instance FromField Date where
328− fromField = ff Date parseDate
328+ fromField = ff Date "Date" parseDate
331− => BuiltinType -> (B8.ByteString -> Either String a)
330+ff :: BuiltinType -> String -> (B8.ByteString -> Either String a)
332 -> Field -> Maybe B8.ByteString -> Conversion a
331 -> Field -> Maybe B8.ByteString -> Conversion a
333−ff pgType parse f mstr =
332+ff pgType hsType parse f mstr =
334 if typeOid f /= builtin2oid pgType
333 if typeOid f /= builtin2oid pgType
335− then returnError Incompatible f ""
334+ then err Incompatible ""
336 else case mstr of
335 else case mstr of
337− Nothing -> returnError UnexpectedNull f ""
336+ Nothing -> err UnexpectedNull ""
338 Just str -> case parse str of
337 Just str -> case parse str of
339− Left msg -> returnError ConversionFailed f msg
338+ Left msg -> err ConversionFailed msg
340 Right val -> return val
339 Right val -> return val
342+ typnam <- typename f
343+ left $ errC (B8.unpack typnam)
345+ (maybe "" B8.unpack (name f))
341{-# INLINE ff #-}
348{-# INLINE ff #-}
343instance (FromField a, FromField b) => FromField (Either a b) where
350instance (FromField a, FromField b) => FromField (Either a b) where