{"record":{"id":"5b7b7d034c85332b","repo":"sharkdp/hexyl","slug":"anyhow-e","errorCode":null,"errorMessage":"anyhow!(e)","messagePattern":"anyhow!\\(e\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":273,"sourceCode":"    Eight,\n}\n\nimpl From<GroupSize> for u8 {\n    fn from(number: GroupSize) -> Self {\n        match number {\n            GroupSize::One => 1,\n            GroupSize::Two => 2,\n            GroupSize::Four => 4,\n            GroupSize::Eight => 8,\n        }\n    }\n}\n\nfn run() -> Result<()> {\n    let opt = Opt::parse();\n\n    if opt.print_color_table {\n        return print_color_table().map_err(|e| anyhow!(e));\n    }\n\n    if let Some(sh) = opt.completion {\n        let mut cmd = Opt::command();\n        let name = cmd.get_name().to_string();\n        generate(sh, &mut cmd, name, &mut io::stdout());\n        return Ok(());\n    }\n\n    let stdin = io::stdin();\n\n    let mut reader = match &opt.file {\n        Some(filename) => {\n            if filename.as_os_str() == \"-\" {\n                Input::Stdin(stdin.lock())\n            } else {\n                if filename.is_dir() {\n                    bail!(\"'{}' is a directory.\", filename.to_string_lossy());","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/sharkdp/hexyl/blob/6ecc29b9c8c84d08a7e860f7f69c22b113b480ea/src/main.rs#L255-L291","documentation":"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.","triggerScenarios":"Invoking b3sum with --color-table (print_color_table) when generating the color table fails (e.g. writing to stdout fails, like a closed pipe).","commonSituations":"Piping --color-table output into `head` causing EPIPE; redirected stdout on a full disk or closed descriptor.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"command -v b3sum >/dev/null && b3sum --color-table >/dev/null 2>&1 || echo 'color table failed'","typeGuard":null,"tryCatchPattern":"match b3sum --color-table output { Ok(t) => use(t), Err(e) if e.kind() == BrokenPipe => ignore, Err(e) => report(e) }","preventionTips":["Avoid piping into commands that close early","Check stdout writability before invoking"],"tags":["cli","anyhow","error-conversion"],"backgroundTag":"api-error-response","analyzedSha":"6ecc29b9c8c84d08a7e860f7f69c22b113b480ea","analyzedAt":"2026-09-09T22:34:15.450Z","contentChangedAt":"2026-09-09T22:34:15.450Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}