Skip to content

Commit

Permalink
make InternalDbException a newtype
Browse files Browse the repository at this point in the history
Change-Id: I596c63d4c612d03bc143551fe8e6ec1e70dbaccd
  • Loading branch information
chessai committed Nov 13, 2024
1 parent 5470a73 commit 0f24b56
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/Chainweb/Pact5/Backend/ChainwebPactDb.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
Expand All @@ -13,10 +14,10 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE BlockArguments #-}

-- TODO pact5: fix the orphan PactDbFor instance
{-# OPTIONS_GHC -Wno-orphans #-}


module Chainweb.Pact5.Backend.ChainwebPactDb
( chainwebPactCoreBlockDb
, Pact5Db(..)
Expand Down Expand Up @@ -106,13 +107,6 @@ import Pact.Core.Command.Types (RequestKey (..))
import Pact.Core.Hash
import qualified Data.HashMap.Strict as HM

data InternalDbException =
InternalDbException Text
deriving (Eq, Show, Typeable)

instance Exception InternalDbException


data BlockHandlerEnv logger = BlockHandlerEnv
{ _blockHandlerDb :: !SQLiteEnv
, _blockHandlerLogger :: !logger
Expand Down Expand Up @@ -187,6 +181,11 @@ callDb callerName action = do
Left err -> internalDbError $ "callDb (" <> callerName <> "): " <> sshow err
Right r -> return r

newtype InternalDbException = InternalDbException Text
deriving newtype (Eq)
deriving stock (Show)
deriving anyclass (Exception)

internalDbError :: MonadThrow m => Text -> m a
internalDbError = throwM . InternalDbException

Expand Down

0 comments on commit 0f24b56

Please sign in to comment.