sharkdp/hexyl · error
anyhow!(e)
Error message
anyhow!(e)
What it means
print_color_table() returns a custom error type; run() converts it into an anyhow::Error via anyhow!(e) so it can propagate through the Result<()> return. The message shown is whatever the underlying error's Display produces.
Solutions
- Check that stdout is writable and not a closed pipe
- Avoid piping color-table output into commands that exit early (e.g. head without pipefail care)
- Inspect the underlying Display message printed after 'Error:' for the root cause
Defensive patterns
Strategy: try-catch
Validate before calling
command -v b3sum >/dev/null && b3sum --color-table >/dev/null 2>&1 || echo 'color table failed'
Try / catch
match b3sum --color-table output { Ok(t) => use(t), Err(e) if e.kind() == BrokenPipe => ignore, Err(e) => report(e) } Prevention
- Avoid piping into commands that close early
- Check stdout writability before invoking
When it happens
Trigger: Invoking b3sum with --color-table (print_color_table) when generating the color table fails (e.g. writing to stdout fails, like a closed pipe).
Common situations: Piping --color-table output into `head` causing EPIPE; redirected stdout on a full disk or closed descriptor.
Related errors
- ' ' is a directory.
- block size argument must be positive
- can not use 'block(s)' as a unit to specify block size
- ByteOffsetParseError::UnitMultiplicationOverflow
- failed to parse `--skip` arg
AI-assisted analysis of sharkdp/hexyl@6ecc29b9c8 (2026-09-09).
Data as JSON: /api/errors/5b7b7d034c85332b.
Report an issue: GitHub.
Appendix: source
Thrown at src/main.rs:273
Eight,
}
impl From<GroupSize> for u8 {
fn from(number: GroupSize) -> Self {
match number {
GroupSize::One => 1,
GroupSize::Two => 2,
GroupSize::Four => 4,
GroupSize::Eight => 8,
}
}
}
fn run() -> Result<()> {
let opt = Opt::parse();
if opt.print_color_table {
return print_color_table().map_err(|e| anyhow!(e));
}
if let Some(sh) = opt.completion {
let mut cmd = Opt::command();
let name = cmd.get_name().to_string();
generate(sh, &mut cmd, name, &mut io::stdout());
return Ok(());
}
let stdin = io::stdin();
let mut reader = match &opt.file {
Some(filename) => {
if filename.as_os_str() == "-" {
Input::Stdin(stdin.lock())
} else {
if filename.is_dir() {
bail!("'{}' is a directory.", filename.to_string_lossy());View on GitHub (pinned to 6ecc29b9c8)