module Database.PostgreSQL.PQTypes.Internal.Exception (
DBException(..)
, rethrowWithContext
) where
import qualified Control.Exception as E
import Database.PostgreSQL.PQTypes.SQL.Class
data DBException = forall e sql. (E.Exception e, Show sql) => DBException {
dbeQueryContext :: !sql
, dbeError :: !e
}
deriving instance Show DBException
instance E.Exception DBException
rethrowWithContext :: IsSQL sql => sql -> E.SomeException -> IO a
rethrowWithContext sql (E.SomeException e) = E.throwIO DBException {
dbeQueryContext = sql
, dbeError = e
}