git.iko.soy/typeable/postgresql-simple
on master help sign in
Export returnError
44f3cd5Leon P Smith
src/Database/PostgreSQL/Simple/Result.hs+6−1
@@ -26,6 +26,7 @@ module Database.PostgreSQL.Simple.Result
26 (
26 (
27 Result(..)
27 Result(..)
28 , ResultError(..)
28 , ResultError(..)
29+ , returnError
29 ) where
30 ) where
30
31
31#include "MachDeps.h"
32#include "MachDeps.h"
@@ -250,9 +251,13 @@ doConvert f types cvt (Just bs)
250doConvert f _ _ _ = returnError UnexpectedNull f ""
251doConvert f _ _ _ = returnError UnexpectedNull f ""
251
252
252
253
254+-- | Given one of the constructors from 'ResultError', the field,
255+-- and an 'errMessage', this fills in the other fields in the
256+-- exception value and returns it in a 'Left . SomeException'
257+-- constructor.
253returnError :: forall a err . (Typeable a, Exception err)
258returnError :: forall a err . (Typeable a, Exception err)
254 => (String -> String -> String -> err)
259 => (String -> String -> String -> err)
255− -> Field -> String -> Status a
260+ -> Field -> String -> Either SomeException a
256returnError mkErr f = left . mkErr (B.unpack (typename f))
261returnError mkErr f = left . mkErr (B.unpack (typename f))
257 (show (typeOf (undefined :: a)))
262 (show (typeOf (undefined :: a)))
258
263