1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-17 02:32:26 +01:00

Replace deprecated 'error-chain' with 'thiserror' (#1820)

We can't use #[from] on Error::Msg(String) because String does not implement Error.
(Which it shouldn't; see e.g. https://internals.rust-lang.org/t/impl-error-for-string/8881.)
So we implement From manually for Error::Msg, since our current code was written
in that way for error-chain.
This commit is contained in:
Martin Nordholts
2021-08-26 13:12:21 +02:00
committed by GitHub
parent f1c0fd7343
commit 19c3e82abf
12 changed files with 83 additions and 77 deletions

View File

@@ -52,7 +52,7 @@ impl OutputType {
use std::process::{Command, Stdio};
let pager_opt =
pager::get_pager(pager_from_config).chain_err(|| "Could not parse pager command.")?;
pager::get_pager(pager_from_config).map_err(|_| "Could not parse pager command.")?;
let pager = match pager_opt {
Some(pager) => pager,
@@ -60,7 +60,7 @@ impl OutputType {
};
if pager.kind == PagerKind::Bat {
return Err(ErrorKind::InvalidPagerValueBat.into());
return Err(Error::InvalidPagerValueBat);
}
let resolved_path = match grep_cli::resolve_binary(&pager.bin) {
@@ -142,7 +142,7 @@ impl OutputType {
OutputType::Pager(ref mut command) => command
.stdin
.as_mut()
.chain_err(|| "Could not open stdin for pager")?,
.ok_or("Could not open stdin for pager")?,
OutputType::Stdout(ref mut handle) => handle,
})
}