git.iko.soy/typeable/postgresql-simple
on master help sign in
Export returnError
commit44f3cd513884796fac9cea785d3c7dd04b6224cc authorLeon P Smith <leon@melding-monads.com> dateMon 6 Feb 2012, 15:51 (15 years ago) parentdd3a6bd
1 file changed+6−1
src/Database/PostgreSQL/Simple/Result.hs+6−1
src/Database/PostgreSQL/Simple/Result.hs+6−1
@@ -26,6 +26,7 @@ module Database.PostgreSQL.Simple.Result
2626 (
2727 Result(..)
2828 , ResultError(..)
29+ , returnError
2930 ) where
3031
3132#include "MachDeps.h"
@@ -250,9 +251,13 @@ doConvert f types cvt (Just bs)
250251doConvert f _ _ _ = returnError UnexpectedNull f ""
251252
252253
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.
253258returnError :: forall a err . (Typeable a, Exception err)
254259 => (String -> String -> String -> err)
255− -> Field -> String -> Status a
260+ -> Field -> String -> Either SomeException a
256261returnError mkErr f = left . mkErr (B.unpack (typename f))
257262 (show (typeOf (undefined :: a)))
258263