Error style
Created by: Mojo4242
Hi,
I often see some programs aborting with expect()
or with an unwrap()
.
This makes message quite not user-friendly.
For examples:
# sudo
thread 'main' panicked at 'sudo: no command provided', rust/src/libcore/option.rs:785
Invalid opcode fault at 23:0000000000413B74
TRACE: FFFFFF400010E318
FFFFFF400010E318: FFFFFF00001224FD
FFFFFF400010E3C8: FFFFFF0000122401
00000180000FF6F0: 0000000000413B69
00000180000FF700: 00000000004065FD
00000180000FF770: 00000000004065EF
00000180000FF7F0: 00000000004067C3
00000180000FF820: 00000000004064F6
00000180000FF890: 0000000000406488
00000180000FF8F0: 0000000000416E0E
00000180000FF960: 0000000000416C18
00000180000FF9D0: 0000000000401AF7
00000180000FFDC0: 0000000000413B5C
00000180000FFDD0: 0000000000406726
00000180000FFE00: 000000000040E0EE
00000180000FFE20: 0000000000406AF4
00000180000FFE80: 000000000041A13C
0000008000000018: EMPTY RETURN
SIGNAL 4, CPU 0, PID ContextId(41)
NAME file:/bin/sudo
Child ended by signal
The essential message here is sudo: no command provided
This lead to the question of style in error management:
- Should we nearly banish
expect()
andunwrap()
, manage error, print an error message to stderr and exit if appropriate ? - Should we abort with these function and adapt them to print a nicer output ?
I would go for 1. as it's makes safer code and when it backtrace, you know that's BAD. I would add a new line about this in rusting_properly
What do you think about that ?