@@ -303,17 +303,13 @@ Suppose you want to throw an error from a component `AnvilEnvironment` of domain
303
303
for example:
304
304
305
305
306
- ``` rust
307
- // replace the first line with the second
308
- let log_file = File :: create (& config . log_file_path)? ;
309
- // Instead of returning `std::io::Error` you now return `anvil::gen::GenericError` containing it
310
- let log_file = File :: create (& config . log_file_path). map_err (to_generic )? ;
311
- ```
312
-
313
- -
314
-
315
- ``` rust
316
- // This is equivalent to `return anyhow!(error)`
306
+ ``` rust
307
+ // replace the first line with the second
308
+ let log_file = File :: create (& config . log_file_path)? ;
309
+ // Instead of returning `std::io::Error` you now return `anvil::gen::GenericError` containing it
310
+ let log_file = File :: create (& config . log_file_path). map_err (to_generic )? ;
311
+
312
+ // This is equivalent to `return anyhow!(error)`
317
313
anyhow :: bail! (
318
314
" fork is using unsupported fee parameters: {:?}" ,
319
315
fork_client . details. fee_params
@@ -331,7 +327,8 @@ return Err(generic_error!(
331
327
" fork is using unsupported fee parameters: {:?}" ,
332
328
fork_client . details. fee_params
333
329
))
334
- ```
330
+ ```
331
+
335
332
2 . Introduce more errors, corresponding to different failure situations.
336
333
337
334
Describe the new error in the JSON file, and replace it on the throw site.
@@ -376,3 +373,5 @@ If a function may return errors that are spread among components (e.g. either
376
373
type ` AnvilError ` from it.
377
374
Such function are rare and require more manual work, but the algorithm is the
378
375
same -- just use ` to_domain ` helper along with ` generic_error! ` macro.
376
+
377
+
0 commit comments