From: Jason Ish Date: Wed, 25 May 2022 17:44:08 +0000 (-0600) Subject: eve-validator: better error messages X-Git-Tag: suricata-5.0.10~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=010cbbda5413071e51bbbf51955e3f555b1d2a49;p=thirdparty%2Fsuricata-verify.git eve-validator: better error messages On file read error and schema parse errors. --- diff --git a/eve-validator/src/main.rs b/eve-validator/src/main.rs index db3b7e771..194f50024 100644 --- a/eve-validator/src/main.rs +++ b/eve-validator/src/main.rs @@ -39,8 +39,12 @@ pub fn main() -> BoxErrorResult<()> { fn validate_instances(instances: &[PathBuf], schema: PathBuf, quiet: bool) -> BoxErrorResult { let mut success = true; - let schema_json = fs::read_to_string(schema)?; - let schema_json = serde_json::from_str(&schema_json)?; + let schema_json = fs::read_to_string(&schema).map_err(|err| { + format!("Failed to read {}: {:?}", schema.display(), err) + })?; + let schema_json = serde_json::from_str(&schema_json).map_err(|err| { + format!("Failed to parse {}: {:?}", schema.display(), err) + })?; match JSONSchema::compile(&schema_json) { Ok(schema) => { for instance in instances {