6
6
module Cardano.DbSync.Error (
7
7
SyncInvariant (.. ),
8
8
SyncNodeError (.. ),
9
+ NodeConfigError (.. ),
9
10
annotateInvariantTx ,
10
11
bsBase16Encode ,
11
12
dbSyncNodeError ,
@@ -50,17 +51,19 @@ data SyncNodeError
50
51
| SNErrCardanoConfig ! Text
51
52
| SNErrInsertGenesis ! String
52
53
| SNErrLedgerState ! String
54
+ | SNErrNodeConfig NodeConfigError
53
55
54
56
instance Exception SyncNodeError
55
57
56
58
instance Show SyncNodeError where
57
59
show =
58
60
\ case
59
- SNErrDefault t -> " Error: " <> Text. show t
60
- SNErrInvariant loc i -> Text. show loc <> " : " <> Text. show (renderSyncInvariant i)
61
+ SNErrDefault t -> " Error SNErrDefault : " <> Text. show t
62
+ SNErrInvariant loc i -> " Error SNErrInvariant: " <> Text. show loc <> " : " <> Text. show (renderSyncInvariant i)
61
63
SNEErrBlockMismatch blkNo hashDb hashBlk ->
62
64
mconcat
63
- [ " Block mismatch for block number "
65
+ [ " Error SNEErrBlockMismatch: "
66
+ , " Block mismatch for block number "
64
67
, show blkNo
65
68
, " , db has "
66
69
, Text. show $ bsBase16Encode hashDb
@@ -69,38 +72,60 @@ instance Show SyncNodeError where
69
72
]
70
73
SNErrIgnoreShelleyInitiation ->
71
74
mconcat
72
- [ " Node configs that don't fork to Shelley directly and initiate"
75
+ [ " Error SNErrIgnoreShelleyInitiation: "
76
+ , " Node configs that don't fork to Shelley directly and initiate"
73
77
, " funds or stakes in Shelley Genesis are not supported."
74
78
]
75
79
SNErrByronConfig fp ce ->
76
80
mconcat
77
- [ " Failed reading Byron genesis file "
81
+ [ " Error SNErrByronConfig: "
82
+ , " Failed reading Byron genesis file "
78
83
, Text. show $ textShow fp
79
84
, " : "
80
85
, Text. show $ textShow ce
81
86
]
82
87
SNErrShelleyConfig fp txt ->
83
88
mconcat
84
- [ " Failed reading Shelley genesis file "
89
+ [ " Error SNErrShelleyConfig: "
90
+ , " Failed reading Shelley genesis file "
85
91
, Text. show $ textShow fp
86
92
, " : "
87
93
, show txt
88
94
]
89
95
SNErrAlonzoConfig fp txt ->
90
96
mconcat
91
- [ " Failed reading Alonzo genesis file "
97
+ [" Error SNErrAlonzoConfig: "
98
+ , " Failed reading Alonzo genesis file "
92
99
, Text. show $ textShow fp
93
100
, " : "
94
101
, show txt
95
102
]
96
103
SNErrCardanoConfig err ->
97
104
mconcat
98
- [ " With Cardano protocol, Byron/Shelley config mismatch:\n "
105
+ [ " Error SNErrCardanoConfig: "
106
+ , " With Cardano protocol, Byron/Shelley config mismatch:\n "
99
107
, " "
100
108
, show err
101
109
]
102
- SNErrInsertGenesis err -> " Error InsertGenesis: " <> err
103
- SNErrLedgerState err -> " Error Ledger State: " <> err
110
+ SNErrInsertGenesis err -> " Error SNErrInsertGenesis: " <> err
111
+ SNErrLedgerState err -> " Error SNErrLedgerState: " <> err
112
+ SNErrNodeConfig err -> " Error SNErrNodeConfig: " <> show err
113
+
114
+ data NodeConfigError
115
+ = NodeConfigParseError String
116
+ | ParseSyncPreConfigError String
117
+ | ReadByteStringFromFileError String
118
+
119
+ instance Exception NodeConfigError
120
+
121
+ instance Show NodeConfigError where
122
+ show =
123
+ \ case
124
+ NodeConfigParseError err -> " NodeConfigParseError - " <> err
125
+ ParseSyncPreConfigError err -> " ParseSyncPreConfigError - " <> err
126
+ ReadByteStringFromFileError err -> " ReadByteStringFromFileError - " <> err
127
+
128
+
104
129
105
130
annotateInvariantTx :: Byron. Tx -> SyncInvariant -> SyncInvariant
106
131
annotateInvariantTx tx ei =
0 commit comments