4 ms·
What is the context that the Go code adds here? When File::create or os.Create fails the errors they return already contain the information what and why somethi
by YmiYugy 11mo ago
What is the context that the Go code adds here?
When File::create or os.Create fails the errors they return already contain the information what and why something failed.
So what information does "failed to create file: " add?
- edflsafoiewq 11mo agoThe error from Rust's File::create basically only contains the errno result. So it's eg. "permission denied" vs "failed to create file: permission denied".
- Mawr 11mo agoWhatever context you deem appropriate at the time of writing that message. Don't overfocus on the example. It could be the request ID, the customer's name — anything that's relevant to that particular call.
- YmiYugy 11mo agoWell if there is useful context Rust let's you add it. You can easily wrap the io error in something specific to your application or just use anyhow with .context("...")? which is what most people do in application code.