This does two big things:
- We add custom error messages and conversions from other error types
into our own error type. This means we can create or modify more
fine grained errors rather than using whatever `failure::Error` gives
us. The first one we have is a `Cli` error, whereby calls to things
like wasm-bindgen or npm failed.
- We also make it so that `PBAR.error()` is called only on exit. We grab
a reference to whatever error gets passed up the chain, have it
generate a message to be printed as an error to PBAR, close up PBAR
like normal, and then print our actual error message to stderr!
The main benefits of this is that as long as we return an error, PBAR
will print and close itself up and we don't need to call it every time
or forget that we would need to call it, and we put error details
specifically into our error!
Closes#12
This commit does quite a few things in order to get this to work:
1. We move all of the code dealing with knowing which command to run
into it's own function. This wrapper command allows us to always
close out PBAR before dumping error output. This fixes a problem
where stderr and stdout were borked and not printing out error
messages correctly.
2. We then refactor the code that has a panic to return early with that
error message.
3. If the command we ran errored, we print out with PBAR that there was
an error with the program we ran (not wasm-pack itself) then dump the
stderr from the command to the actual stderr
This means we can abort early on without continuing any of the other
parts of wasm-pack and let the user know what the error was rather than
just saying "There's an error"