servo/components/util
bors-servo 7aedb9c7cd Auto merge of #9600 - danlrobertson:opts_parser_err, r=ecoal95
Add informative error messages when parsing command line options returns an error

The background behind why I'm submitting this PR is slightly embarrassing. After running `./mach` with some servo options I got the following stack backtrace.

```
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', ../src/libcore/result.rs:746
stack backtrace:
   1:     0x56459001b0b0 - sys::backtrace::tracing:👿:write::hb120982054a416e35nu
   2:     0x56459001e02b - panicking::default_handler::_$u7b$$u7b$closure$u7d$$u7d$::closure.42840
   3:     0x56459001dc96 - panicking::default_handler::h7ae2e4523ef4c187IFy
   4:     0x56459000760c - sys_common::unwind::begin_unwind_inner::h5fb19481d14902dbDgt
   5:     0x564590007cf8 - sys_common::unwind::begin_unwind_fmt::hd62d57279546b0f2Jft
   6:     0x56459001a701 - rust_begin_unwind
   7:     0x56459004c01f - panicking::panic_fmt::h27f7225e08792f40qYL
   8:     0x56458f393901 - result::unwrap_failed::h18215968003310890981
                        at ../src/libcore/macros.rs:29
   9:     0x56458f3937b9 - result::Result<T, E>::unwrap::h10319050269194353824
                        at ../src/libcore/result.rs:687
  10:     0x56458f383701 - opts::from_cmdline_args::h8ea8d8c87dc6ee726lg
                        at /home/drobertson/git/servo/components/util/opts.rs:599
  11:     0x56458d1f8cdf - main::h8517eb49d15e90fbNaa
                        at /home/drobertson/git/servo/components/servo/main.rs:53
  12:     0x56459001d8f4 - sys_common::unwind::try::try_fn::h9076850075504893162
  13:     0x56459001a68b - __rust_try
  14:     0x56459001d36e - rt::lang_start::h58a22f304b0c1e19Oxy
  15:     0x56458d2f4aa9 - main
  16:     0x7f370496360f - __libc_start_main
  17:     0x56458d1c04a8 - _start
  18:                0x0 - <unknown>
Servo exited with return value 101
```

I immediately opened up `gdb` and got to work only to realize that the error was due to a typo in an option that had been `unwrap`ed at [components/util/opts.rs:599](https://github.com/servo/servo/blob/master/components/util/opts.rs#L599). Perhaps some more informative error messages will help prevent some future face-palm moments like mine 😄

I couldn't think of a good way to add tests for this. Please let me know if I missed something. Comments and critiques are welcome!

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9600)
<!-- Reviewable:end -->
2016-02-16 23:13:55 +05:30
..
deque Fix issues found by rust-clippy 2015-10-12 20:21:49 -04:00
cache.rs Upgrade to new Hasher API 2016-02-03 20:06:39 +01:00
Cargo.toml Refactor style to be completely backend-independent 2016-02-13 16:05:14 +01:00
debug_utils.rs Issue #9042: Report incorrect number of spaces around => in the style checker. 2015-12-23 20:54:26 +01:00
geometry.rs Say farewell to in-tree HeapSizeOf 2016-02-04 22:03:32 +01:00
ipc.rs Update ipc-channel to pick up the improved error reporting. 2015-11-23 16:38:39 -08:00
lib.rs Auto merge of #9636 - nox:mv-cursor, r=Ms2ger 2016-02-16 16:50:20 +05:30
linked_list.rs util: Remove the old broken SerializableLinkedList code in favor of 2015-07-31 08:42:29 -07:00
logical_geometry.rs Say farewell to in-tree HeapSizeOf 2016-02-04 22:03:32 +01:00
non_geckolib.rs Say farewell to in-tree HeapSizeOf 2016-02-04 22:03:32 +01:00
opts.rs Add error messages when parsing opts returns error 2016-02-10 23:13:15 -05:00
persistent_list.rs Fix issues found by rust-clippy 2015-10-12 20:21:49 -04:00
prefs.rs Fix a bunch of clippy lints 2016-01-02 23:27:15 +01:00
print_tree.rs Improve printing of DisplayLists 2015-09-16 12:31:38 -07:00
range.rs Say farewell to in-tree HeapSizeOf 2016-02-04 22:03:32 +01:00
resource_files.rs Fix a bunch of clippy lints 2016-01-02 23:27:15 +01:00
str.rs refactor, moving functions into attr and htmlfontelemend fixes #9639 #9638 2016-02-15 22:33:14 +00:00
thread.rs task -> thread 2016-01-10 17:58:13 +09:00
thread_state.rs task -> thread 2016-01-10 17:58:13 +09:00
threadpool.rs task -> thread 2016-01-10 17:58:13 +09:00
tid.rs task -> thread 2016-01-10 17:58:13 +09:00
time.rs Use thread::sleep instead of deprecated sleep_ms 2015-11-29 13:41:04 -07:00
vec.rs Fix issues found by rust-clippy 2015-10-12 20:21:49 -04:00
workqueue.rs Cargo updates and small workqueue change 2016-01-20 08:38:27 -06:00