|
|
|
|
|
by Animats
1316 days ago
|
|
After several false starts, Rust mostly got this right with returning Result<usefulresult, Error>
from most functions, and using "?" for "If the result of this is Error, do a return of the error". There's also a thing where you can write foo().context("useful info about foo")?
and pass some more info with the error.Plus, most things that work like "open" close when their scope closes, so you don't need all that "defer" stuff. I would have liked a good error hierarchy like Python 2 had, where there was a clear distinction between program-is-broken errors and errors due to external causes. But Rust didn't get that at the beginning, and now it's too late. |
|
anyhow::Error really does a good job of smoothing out the finicky bits of Rust error handling, it feels and reads a lot better than Go code to me.