Commit 1ebc919
committed
refactor: cleanup usages of the
- Remove redundant `.map_err(|err| anyhow!(err))` when used before a
`with_context` as it does the error conversion.
- Remove redundant `format!` in `anyhow!(format!(..))` as the anyhow
macro already support formatting.
- Prefer usage of `with_context` instead of `ok_or(anyhow!(..))` or
`ok_or_else(|| anyhow!(..))` when working with options, so the
error conversion is gracefully done by the anyhow crate instead of
our code, and this often results in leaner code.
- Simplify `anyhow::anyhow!(e).context(..)` to `e.context(..)` when
the error is already an anyhow error.
- When using the macro is unavoidable and it print the error in its
message, add another context layer by wrapping the error first then
adding the previous message as context.
e.g: from `anyhow!("Error context: {e}")` to
`anyhow!(e.to_string()).context("Error context")`.
- Add a anyhow context to some errors.
Note: Some macro usage are unavoidable, e.g when the inner error can't
be implicitly converted to `anyhow::Error`.anyhow! macro1 parent 2cd85d6 commit 1ebc919
File tree
79 files changed
+362
-415
lines changed- examples
- client-cardano-database-v2/src
- client-cardano-database/src
- client-cardano-stake-distribution/src
- client-mithril-stake-distribution/src
- internal
- cardano-node
- mithril-cardano-node-chain/src
- chain_observer
- chain_reader
- entities
- mithril-cardano-node-internal-database/src
- mithril-aggregator-client/src
- mithril-dmq/src
- consumer
- client
- server
- publisher/server
- test/double
- mithril-era/src
- adapters
- mithril-protocol-config/src
- mithril-ticker/src
- mithril-aggregator
- src
- artifact_builder
- cardano_database_artifacts
- commands
- dependency_injection/builder/enablers
- event_store/database
- file_uploaders
- cloud_uploader
- services
- certificate_chain_synchronizer
- signer_registration
- tools
- file_archiver
- tests/test_extensions
- mithril-client-cli/src
- commands
- cardano_db
- cardano_stake_distribution
- cardano_transaction
- tools/utxo_hd
- utils
- archive_unpacker
- github_release_retriever
- mithril-client-wasm/src
- mithril-client/src
- cardano_database_client/download_unpack
- certificate_client
- file_downloader
- utils
- mithril-common/src
- certificate_chain
- crypto_helper
- cardano
- kes
- codec
- messages
- protocol
- signable_builder
- mithril-relay/src/relay
- mithril-signer
- src
- dependency_injection
- services
- signable_builder
- signature_publisher
- tests/test_extensions
- mithril-test-lab/mithril-aggregator-fake/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
79 files changed
+362
-415
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
88 | | - | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | | - | |
72 | | - | |
73 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
Lines changed: 0 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
78 | | - | |
79 | 77 | | |
80 | 78 | | |
81 | 79 | | |
82 | 80 | | |
83 | | - | |
84 | 81 | | |
85 | 82 | | |
86 | 83 | | |
| |||
91 | 88 | | |
92 | 89 | | |
93 | 90 | | |
94 | | - | |
95 | 91 | | |
96 | 92 | | |
97 | 93 | | |
98 | 94 | | |
99 | | - | |
100 | 95 | | |
101 | 96 | | |
102 | 97 | | |
103 | 98 | | |
104 | | - | |
105 | 99 | | |
106 | 100 | | |
107 | 101 | | |
| |||
129 | 123 | | |
130 | 124 | | |
131 | 125 | | |
132 | | - | |
133 | 126 | | |
134 | 127 | | |
135 | 128 | | |
| |||
170 | 163 | | |
171 | 164 | | |
172 | 165 | | |
173 | | - | |
174 | 166 | | |
175 | 167 | | |
176 | 168 | | |
177 | 169 | | |
178 | | - | |
179 | 170 | | |
180 | 171 | | |
181 | 172 | | |
182 | | - | |
183 | 173 | | |
184 | 174 | | |
185 | 175 | | |
186 | 176 | | |
187 | 177 | | |
188 | 178 | | |
189 | | - | |
190 | 179 | | |
191 | 180 | | |
192 | 181 | | |
| |||
200 | 189 | | |
201 | 190 | | |
202 | 191 | | |
203 | | - | |
204 | 192 | | |
205 | 193 | | |
206 | 194 | | |
207 | 195 | | |
208 | | - | |
209 | 196 | | |
210 | 197 | | |
211 | 198 | | |
212 | 199 | | |
213 | | - | |
214 | 200 | | |
215 | 201 | | |
216 | 202 | | |
| |||
219 | 205 | | |
220 | 206 | | |
221 | 207 | | |
222 | | - | |
223 | 208 | | |
224 | 209 | | |
225 | 210 | | |
| |||
282 | 267 | | |
283 | 268 | | |
284 | 269 | | |
285 | | - | |
286 | 270 | | |
287 | 271 | | |
288 | 272 | | |
289 | 273 | | |
290 | 274 | | |
291 | 275 | | |
292 | 276 | | |
293 | | - | |
294 | 277 | | |
295 | 278 | | |
296 | 279 | | |
| |||
300 | 283 | | |
301 | 284 | | |
302 | 285 | | |
303 | | - | |
304 | 286 | | |
305 | 287 | | |
306 | 288 | | |
| |||
310 | 292 | | |
311 | 293 | | |
312 | 294 | | |
313 | | - | |
314 | 295 | | |
315 | 296 | | |
316 | 297 | | |
| |||
324 | 305 | | |
325 | 306 | | |
326 | 307 | | |
327 | | - | |
328 | 308 | | |
329 | 309 | | |
330 | 310 | | |
| |||
335 | 315 | | |
336 | 316 | | |
337 | 317 | | |
338 | | - | |
339 | 318 | | |
340 | 319 | | |
341 | 320 | | |
| |||
365 | 344 | | |
366 | 345 | | |
367 | 346 | | |
368 | | - | |
369 | 347 | | |
370 | 348 | | |
371 | 349 | | |
| |||
389 | 367 | | |
390 | 368 | | |
391 | 369 | | |
392 | | - | |
393 | 370 | | |
394 | 371 | | |
395 | 372 | | |
396 | 373 | | |
397 | 374 | | |
398 | | - | |
399 | 375 | | |
400 | 376 | | |
401 | 377 | | |
| |||
407 | 383 | | |
408 | 384 | | |
409 | 385 | | |
410 | | - | |
411 | 386 | | |
412 | 387 | | |
413 | 388 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
Lines changed: 16 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 34 | + | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
| |||
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
66 | 65 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
76 | 73 | | |
77 | 74 | | |
78 | 75 | | |
79 | 76 | | |
80 | 77 | | |
81 | | - | |
| 78 | + | |
82 | 79 | | |
83 | 80 | | |
84 | 81 | | |
| |||
90 | 87 | | |
91 | 88 | | |
92 | 89 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 90 | + | |
| 91 | + | |
96 | 92 | | |
97 | 93 | | |
98 | 94 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
| |||
0 commit comments