-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(core): avoid unwrap, expect, panic in persistence.rs #259
Conversation
@racs4 I added a kindelia_core::util::FileSystemError. The purpose is to wrap std::io::Error for any filesystem calls, so that path and optionally context can be reported to the user. Otherwise the user gets "write failed os error(27)" type errors, without even knowing the file. This is a pain point in rust, and it seems like they might address it soon. The new error type enables SimpleFileStorage to return rich errors cleanly, as path info does not necessarily belong in BlockStorageError. It should also be useful for other places that presently return IoResult, for example. Basically any code that interacts with filesystem. Also, I notice that if a review has been requested and not yet performed and then another commit is pushed, CI does not run. And there is no way to request another review. I found that a workaround is to convert the PR to a draft and then back to a regular PR, at which point checks run again. |
persistence: * add BlockStorageError enum * modify BlockStorage trait to return Result for reads, writes. * modify SimpleFileStorage to return Result for reads, writes * modify EmptyStorage to return Result for reads, writes * log error instead of panic when block write thread hits error * minor rustfmt tweaks node: * add NodeError enum * log errors from BlockStorage read, write bench: * ignore Result from BlockStorage write
Adds an error type for wrapping std::io::Error and providing path and context metadata. Initially it is used by SimpleFileStorage but it is intended for use by any fn that calls std lib file functions with a path.
uses FileSystemError in a couple places in SimpleFileStorage that were missed previously.
I will try to fix this. |
Addresses #247. (more to come)
This PR focuses on persistence.rs. Modifications to other files are just to handle the persistence changes.
persistence.rs:
node.rs: