Description
Rust's current error handling story is quite good for programming in the large. But for small programs, the overhead of matching the outermost Result
, printing the error, and returning the proper error code is quite tedious in comparison to temptation of just panicking.
Furthermore, interactive tools shouldn't print a message implying the program is broken on bad manual input, yet such an "internal error" is exactly what the panic message applies. So there is no nice, succinct way to handle input errors with bubbling results or panics.
Allowing main
to return a result would make our error handling story both compositional and succinct on programs on all sizes. Furthermore, should there be any platform-specific requirements/idioms for error-codes, etc, we can handle them transparently. While this does make main
a bit more complex, there is already a shim between start
and main
with both C and Rust, so we're already down that rabbit hole.
I was told by @eddyb this was already a wanted feature, but @steveklabnik didn't see an open issue so I made this.