git.delta.rocks / jrsonnet / refs/commits / 7de62040eec5

difftreelog

source

crates/nix-eval/src/util.rs845 Bsourcehistory
1use anyhow::bail;2use tracing::{debug, warn};3use std::time::Instant;45use crate::{nix_go_json, Value};67pub async fn assert_warn(action: &str, val: &Value) -> anyhow::Result<()> {8	let before_errors = Instant::now();9	let errors: Vec<String> = nix_go_json!(val.errors);10	debug!("errors evaluation took {:?}", before_errors.elapsed());11	if !errors.is_empty() {12		bail!(13			"{action} failed with error{}{}",14			(errors.len() != 1).then_some("s:\n- ").unwrap_or(": "),15			errors.join("\n- "),16		);17	}1819	let before_errors = Instant::now();20	let warnings: Vec<String> = nix_go_json!(val.warnings);21	debug!("warnings evaluation took {:?}", before_errors.elapsed());22	if !warnings.is_empty() {23		warn!(24			"{action} completed with warning{}{}",25			(warnings.len() != 1).then_some("s:\n- ").unwrap_or(": "),26			warnings.join("\n- "),27		);28	}29	Ok(())30}