diff options
author | nickelc <constantin.nickel@gmail.com> | 2023-04-26 21:07:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-26 15:07:35 -0400 |
commit | ce41a39bf6ebd3b7bbac4c73954cf6078ed96fc5 (patch) | |
tree | 964301063730884f4b23280fe72dd9900c3432ae /src/utils/bat/output.rs | |
parent | 57e7ce5cd55d127bc33822318cd66b3b6a14f6ec (diff) |
Replace deprecated `error_chain` crate with `anyhow` (#1405)
The `error_chain` crate is now deprecated for a long time and `anyhow`
has proven to be a popular replacement for applications.
This also improves the current error messages for panics.
```
PAGER='"less' git show
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: \
Error(Msg("Could not parse pager command."), State { next_error: Some(ParseError), \
backtrace: InternalBacktrace })', src/main.rs:136:88
```
```
PAGER='"less' git show
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Could not parse pager command.
Caused by:
missing closing quote', src/main.rs:125:88
```
Diffstat (limited to 'src/utils/bat/output.rs')
-rw-r--r-- | src/utils/bat/output.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/utils/bat/output.rs b/src/utils/bat/output.rs index de02b18e..ca062e1b 100644 --- a/src/utils/bat/output.rs +++ b/src/utils/bat/output.rs @@ -74,8 +74,7 @@ impl OutputType { .or(pager_from_env) .unwrap_or_else(|| String::from("less")); - let pagerflags = - shell_words::split(&pager).chain_err(|| "Could not parse pager command.")?; + let pagerflags = shell_words::split(&pager).context("Could not parse pager command.")?; Ok(match pagerflags.split_first() { Some((pager_name, args)) => { @@ -117,7 +116,7 @@ impl OutputType { OutputType::Pager(ref mut command) => command .stdin .as_mut() - .chain_err(|| "Could not open stdin for pager")?, + .context("Could not open stdin for pager")?, OutputType::Stdout(ref mut handle) => handle, }) } |