packages feed

hasql-pool-1.5.1.0 / src / library / Hasql / Pool / SessionErrorDestructors.hs

module Hasql.Pool.SessionErrorDestructors whereimport Hasql.Errors qualified as Errorsimport Hasql.Pool.Preludereset :: (Text -> x) -> x -> Errors.SessionError -> xreset onReset onNoReset = \case  Errors.ConnectionSessionError details -> onReset details  _ -> onNoResetrequiresConnectionDiscard :: Errors.SessionError -> BoolrequiresConnectionDiscard = \case  Errors.ConnectionSessionError {} -> True  Errors.MissingTypesSessionError {} -> True  Errors.ScriptSessionError _ serverError -> isStaleServerError serverError  Errors.StatementSessionError _ _ _ _ _ statementError -> statementRequiresConnectionDiscard statementError  -- Driver errors indicate that Hasql or the server left the connection in an  -- unexpected state. In particular, Hasql closes the libpq connection when  -- cleanup after an interruption fails, so it must not be reused by the pool.  Errors.DriverSessionError {} -> TruediscardDetails :: Errors.SessionError -> Maybe TextdiscardDetails err =  if requiresConnectionDiscard err    then Just $ Errors.toMessage err    else NothingstatementRequiresConnectionDiscard :: Errors.StatementError -> BoolstatementRequiresConnectionDiscard = \case  Errors.ServerStatementError serverError -> isStaleServerError serverError  Errors.UnexpectedColumnTypeStatementError {} -> True  _ -> FalseisStaleServerError :: Errors.ServerError -> BoolisStaleServerError (Errors.ServerError code _ _ _ _) =  code == "0A000" || code == "XX000"