this post was submitted on 23 Nov 2023
41 points (91.8% liked)
Rust
5999 readers
7 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Do you really discard errors this often? I would say almost all of my
Result
s get propagated to the caller via?
and handled in one place near the start of the stack.A lot of the time, I have these around places where I'm reading from a file. If reading causes an error, regardless of what the error is, I just return None and a new file is created.
That is a terrible time to throw away the error. Best to actually check for file not exists error and created the file only then. Other errors are important to see to debug why things are failing.
It is very annoying to have a tool tell you it failed to create a file when the file exists but it just cannot read it for some reason. You can spend ages jumping down the wrong rabbit whole if you don't realize what is happening.
Yeah that's a good point. This is a special case where the file is simply caching runtime results so errors surrounding it not being read aren't a big deal.