Skip to content

Commit 0a31bfd

Browse files
committed
devide queries and use statements
1 parent a01778e commit 0a31bfd

25 files changed

+3101
-3578
lines changed

Diff for: cardano-db/cardano-db.cabal

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ library
102102
, filepath
103103
, file-embed
104104
, hasql
105-
, hasql-transaction
106105
, iohk-monitoring
107106
, lifted-base
108107
, memory

Diff for: cardano-db/src/Cardano/Db/Error.hs

+36-35
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
{-# LANGUAGE DeriveGeneric #-}
2-
{-# LANGUAGE LambdaCase #-}
3-
{-# LANGUAGE OverloadedStrings #-}
41
{-# LANGUAGE RankNTypes #-}
52

63
module Cardano.Db.Error (
7-
AsDbError (..),
4+
-- AsDbError (..),
85
CallSite (..),
96
DbError (..),
107
runOrThrowIODb,
@@ -14,53 +11,57 @@ module Cardano.Db.Error (
1411
) where
1512

1613
import Cardano.BM.Trace (Trace, logError)
17-
import Cardano.Db.Schema.Ids
1814
import Cardano.Prelude (throwIO, MonadIO)
1915
import Control.Exception (Exception)
2016
import Data.ByteString.Char8 (ByteString)
2117
import Data.Text (Text)
22-
import Data.Word (Word16, Word64)
23-
import GHC.Generics (Generic)
2418
import qualified Data.ByteString.Base16 as Base16
2519
import qualified Data.Text.Encoding as Text
26-
import qualified Hasql.Session as HsqlS
2720

28-
class AsDbError e where
29-
toDbError :: DbError -> e
30-
fromDbError :: e -> Maybe DbError
21+
import qualified Hasql.Session as HsqlSes
3122

32-
data DbError
33-
= DbError !CallSite !Text !HsqlS.SessionError
34-
| DbLookupError !CallSite !Text !LookupContext
35-
deriving (Show, Eq)
23+
data DbError = DbError
24+
{ dbErrorCallSite :: !CallSite
25+
, dbErrorMessage :: !Text
26+
, dbErrorCause :: !(Maybe HsqlSes.SessionError) -- Now a Maybe
27+
}
3628

37-
instance Exception DbError
29+
-- class AsDbError e where
30+
-- toDbError :: DbError -> e
31+
-- fromDbError :: e -> Maybe DbError
32+
33+
-- data DbError
34+
-- = DbError !CallSite !Text !HsqlS.SessionError
35+
-- | DbLookupError !CallSite !Text !LookupContext
36+
-- deriving (Show, Eq)
37+
38+
-- instance Exception DbError
3839

3940
data CallSite = CallSite
4041
{ csModule :: !Text
4142
, csFile :: !Text
4243
, csLine :: !Int
4344
} deriving (Show, Eq)
4445

45-
data LookupContext
46-
= BlockHashContext !ByteString
47-
| BlockIdContext !Word64
48-
| MessageContext !Text
49-
| TxHashContext !ByteString
50-
| TxOutPairContext !ByteString !Word16
51-
| EpochNoContext !Word64
52-
| SlotNoContext !Word64
53-
| GovActionPairContext !TxId !Word64
54-
| MetaEmptyContext
55-
| MetaMultipleRowsContext
56-
| MultipleGenesisContext
57-
| ExtraMigrationContext !String
58-
| PruneConsumedContext !String
59-
| RJsonbInSchemaContext !String
60-
| TxOutVariantContext !String
61-
deriving (Show, Eq, Generic)
62-
63-
instance Exception LookupContext
46+
-- data LookupContext
47+
-- = BlockHashContext !ByteString
48+
-- | BlockIdContext !Word64
49+
-- | MessageContext !Text
50+
-- | TxHashContext !ByteString
51+
-- | TxOutPairContext !ByteString !Word16
52+
-- | EpochNoContext !Word64
53+
-- | SlotNoContext !Word64
54+
-- | GovActionPairContext !TxId !Word64
55+
-- | MetaEmptyContext
56+
-- | MetaMultipleRowsContext
57+
-- | MultipleGenesisContext
58+
-- | ExtraMigrationContext !String
59+
-- | PruneConsumedContext !String
60+
-- | RJsonbInSchemaContext !String
61+
-- | TxOutVariantContext !String
62+
-- deriving (Show, Eq, Generic)
63+
64+
-- instance Exception LookupContext
6465

6566
-- catchDbError :: String -> HsqlT.Transaction a -> HsqlT.Transaction a
6667
-- catchDbError context action =

0 commit comments

Comments
 (0)