4 ms·
Existing error handling facilities in Rust may not suit every use-case. For me personally, the difficulty with the `?` operator (and try! macro) is that the Fil
by test9753 9y ago
Existing error handling facilities in Rust may not suit every use-case. For me personally, the difficulty with the `?` operator (and try! macro) is that the File + Line info about the source of error is lost. Also, I want something simpler than the approach taken by the `error-chain` crate. My current solution is to use some custom macros to check for errors and display an execution trace (example here: https://play.rust-lang.org/?gist=a7fb903ce2bbb37914ab380d342f6df2&version=stable https://play.rust-lang.org/?gist=a7fb903ce2bbb37914ab380d342... )
- tmzt 9y agoDoes rust have __FILE__ etc.? Special constants?
- steveklabnik 9y agohttps://doc.rust-lang.org/stable/std/macro.file.html https://doc.rust-lang.org/stable/std/macro.file.html https://doc.rust-lang.org/stable/std/macro.line.html https://doc.rust-lang.org/stable/std/macro.line.html https://doc.rust-lang.org/stable/std/macro.column.html https://doc.rust-lang.org/stable/std/macro.column.html