> With things like try! and the various helper methods on Result/Option, passing errors around is supposed to be easier than in other languages. I haven't done much with it, so I don't know how well it works.
I can attest to it working quite well. > What would be Rust alternative, except passing the errors all around parser? Doesn't it grow parser code by at least 50%? I'm actually writing the next version of "Practicality With Rust" covering error handling, as that's a popular request for new comers coming from exception-based, or -1 based languages. The `try!` macro, along with functions like `map_err()` allow you to implement custom error and result types similar to `IoError` and `IoResult`, respectively. [Cargo currently does this, too.]( https://github.com/carlhuda/cargo/blob/master/src/cargo/util/result.rs) -- Daniel Fagnan @TheHydroImpulse http://hydrocodedesign.com M: (780) 983-4997 On Thu, May 29, 2014 at 12:45 PM, comex <[email protected]> wrote: > On Thu, May 29, 2014 at 2:32 PM, Oleg Eterevsky <[email protected]> > wrote: > > What would be Rust alternative, except passing the errors all around > > parser? Doesn't it grow parser code by at least 50%? > > With things like try! and the various helper methods on Result/Option, > passing errors around is supposed to be easier than in other > languages. I haven't done much with it, so I don't know how well it > works. > > You can also spawn a task for the parser, since the internal parser > data structures don't need to be kept around after failure or > anything; as mentioned in a previous post, a better way to do this > synchronously on the same thread might be added. > > Of course, depending on what you're parsing, you may want to continue > after errors to report further problems, in which case the exception > version wouldn't work anyway. > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
