Report formatter output on error (#104)

This commit is contained in:
Basile Henry 2021-04-11 14:30:51 +02:00 committed by GitHub
parent 05f612bd08
commit 63c58e4f55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
use crate::config::FmtConfig;
use crate::{expand_if_path, expand_path};
use anyhow::{anyhow, Result};
use console::style;
use globset::{GlobBuilder, GlobSet, GlobSetBuilder};
use log::debug;
use path_clean::PathClean;
@ -96,6 +97,14 @@ impl Formatter {
match cmd_arg.output() {
Ok(out) => {
if !out.status.success() {
debug!(
"Error using formatter {}:\n{stdout}:\n{}\n{stderr}:\n{}",
self.name,
String::from_utf8_lossy(&out.stdout),
String::from_utf8_lossy(&out.stderr),
stdout = style("• [STDOUT]").bold().dim(),
stderr = style("• [STDERR]").bold().dim(),
);
match out.status.code() {
Some(scode) => {
return Err(anyhow!(