Make error messages nicer (#551)
* Remove unhelpful information from errors
Before:
```
Git repositories failed:
0: error: cannot pull with rebase: You have unstaged changes.
error: Please commit or stash them.
0:
Location:
src/steps/git.rs:39
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
```
After:
```
Git repositories failed:
0: Failed to pull /Users/wiggles/.dotfiles
1: error: cannot pull with rebase: You have unstaged changes.
error: Please commit or stash them.
Location:
src/steps/git.rs:39
```
* Improve git_repos errors
This removes the extra blank "0:" line at the end of the error, doesn't
print the error message twice, and provides the repo path in the error
message.
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -47,7 +47,7 @@ pub static XDG_DIRS: Lazy<Xdg> = Lazy::new(|| Xdg::new().expect("No home directo
|
||||
pub static WINDOWS_DIRS: Lazy<Windows> = Lazy::new(|| Windows::new().expect("No home directory"));
|
||||
|
||||
fn run() -> Result<()> {
|
||||
color_eyre::install()?;
|
||||
install_color_eyre()?;
|
||||
ctrlc::set_handler();
|
||||
|
||||
let opt = CommandLineArgs::parse();
|
||||
@@ -571,3 +571,16 @@ fn install_tracing(filter_directives: &str) -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn install_color_eyre() -> Result<()> {
|
||||
color_eyre::config::HookBuilder::new()
|
||||
// Don't display the backtrace reminder by default:
|
||||
// Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
|
||||
// Run with RUST_BACKTRACE=full to include source snippets.
|
||||
.display_env_section(false)
|
||||
// Display location information by default:
|
||||
// Location:
|
||||
// src/steps.rs:92
|
||||
.display_location_section(true)
|
||||
.install()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user