Comments (3)
Hi! Thanks for the lovely, thoughtful issue! I'm honestly fairly new to Rust and haven't gotten used to how error patterns are supposed to written.
My first thought is that this should re-export anyhow::Error
to start.
Or maybe the expected pattern is to have users just expect impl std::error::Error
? What would work best for you, since you're an actual user? I don't mind making breaking changes!
from cacache-rs.
Thanks for your quick response. I am also new to Rust and currently in the exactly same boat as you in regards to error handling.
For my current use case I just need the ability to wrap cacaches errors and an exposed anyhow error would solve that issue nicely. I am not sure if tying your major version to that of anyhow is worth it though.
Consumers would also have no ability to distinguish between error types (I guess EntryNotFound
might be very useful e.g.).
What I have seen in other library crates is to expose an error enum with specific, relevant members and wrap any underlying errors inside of it (which I think was your original approach).
The big tradeoff seems to be being able to treat all errors the same and therefore being able to easily add context vs. clearly communicating error states to the outside world. The author of the thiserror
and anyhow
crates apparently draws the line between "application" and library crates: https://github.com/dtolnay/anyhow#comparison-to-thiserror
In my own code I would probably resort to using a backtrace (which thiserror can attach automatically) to figure out the callchain and wrap errors of underlying libraries manually. And if additional context for an error type is important, add an additional entry to the error enum.
I am not sure how important custom error context is to you. If you don't mind replacing it with a backtrace for the general case, I would attempt the above approach in a PR to see how it feels.
Edit:
I just realised, std::backtrace
is nightly only, so that might be a dealbreaker.
from cacache-rs.
closed by #24 :)
from cacache-rs.
Related Issues (20)
- feature request: tokio::io::AsyncSeek support for Reader HOT 5
- about High frequency writing and deletion HOT 1
- Validation of documented system properties
- Fully deletion does not delete the value HOT 2
- Compilation error HOT 2
- feature request: cacache::Writer without a key HOT 2
- Multiple file hashes HOT 1
- Feature "tokio" does not compile with rustc 1.77.1 HOT 3
- Remove Key and clean the value
- The way I'm using cacache is very slow HOT 6
- "raw_metadata" is not raw after serialization HOT 3
- Deadlock when accessing across two threads. HOT 2
- Is cacache checking for hash collisions? HOT 1
- reading from a cacache::WriteOpts Writer, before its completed HOT 3
- Cannot delete fully index entry if content file doesn't exist.
- Some variants for copy/reflink/hard-link are missed
- [Question] Why the size of buf is not consistent?
- file corruption on Windows HOT 7
- Unwrap on Error for Tokio Join Handle
- Lockless? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cacache-rs.