Errors should be composed of reusable parts to make readability consistent.
What if handling an error also produces an error?
code:
Lines 822 to 838 in 51686e4
command (try it yourself):
$ cargo test -- test::error_in_error_handling --nocapture
output:
![image](https://private-user-images.githubusercontent.com/11223234/294106702-bed07095-64ad-4fc4-bd5d-c770f6c4b19c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwODM0MTEsIm5iZiI6MTczOTA4MzExMSwicGF0aCI6Ii8xMTIyMzIzNC8yOTQxMDY3MDItYmVkMDcwOTUtNjRhZC00ZmM0LWJkNWQtYzc3MGY2YzRiMTljLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDA2MzgzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgyYTU1NjA4OGVhM2I5ZGMzMDBmMzBkZDEwMjdiZTZkYzI4NTgwNTlmOGZiNWI4NmRmNGY1ODBlODE5OTUyM2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.05BHZff9ofWIaIejJWslhCvg8m0Ytac1dYjIMCFk3lc)
If just
is installed: just printerr-all
to visualize all unit test errors
-- This error crate is intended to
-- enhance error-stack:
-- https://hash.dev/blog/announcing-error-stack
-- error-stack `is_fantastic && does_things.in(|_a| functional(approach))` but
-- `error_stack::Report::change_context` can make code noisy when used often
--
-- ...so why not auto implement a bunch of `From<Error> for MyError`?
-- and provide fundamental building blocks such as `bigerror::NotFound`
-- to express common causes for errors and imply correlation?
CREATE CRATE IF NOT EXISTS
bigerror (
error BIGERROR NOT NULL,
);