Browse files

add fieldname to incompatible error for nicer errors

  • Loading branch information...
1 parent 98e7e75 commit 173a3b40475f332810eccdb82199680b2039d406 @bitemyapp bitemyapp committed May 27, 2015
Showing with 4 additions and 1 deletion.
  1. +4 −1 Database/MySQL/Simple/Result.hs
View
5 Database/MySQL/Simple/Result.hs
@@ -61,6 +61,7 @@ import System.Locale (defaultTimeLocale)
-- value fails.
data ResultError = Incompatible { errSQLType :: String
, errHaskellType :: String
+ , errFieldName :: String
, errMessage :: String }
-- ^ The SQL and Haskell types are not compatible.
| UnexpectedNull { errSQLType :: String
@@ -221,7 +222,9 @@ doConvert f _ cvt _ = throw $ UnexpectedNull (show (fieldType f))
(show (typeOf (cvt undefined))) ""
incompatible :: Field -> TypeRep -> String -> a
-incompatible f r = throw . Incompatible (show (fieldType f)) (show r)
+incompatible f r = throw . Incompatible (show (fieldType f))
+ (show r)
+ (B8.unpack (fieldName f))
conversionFailed :: Field -> String -> String -> a
conversionFailed f s = throw . ConversionFailed (show (fieldType f)) s

0 comments on commit 173a3b4

Please sign in to comment.