]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
eve-validator: better error messages
authorJason Ish <jason.ish@oisf.net>
Wed, 25 May 2022 17:44:08 +0000 (11:44 -0600)
committerJason Ish <jason.ish@oisf.net>
Fri, 3 Jun 2022 19:55:44 +0000 (13:55 -0600)
On file read error and schema parse errors.

eve-validator/src/main.rs

index db3b7e7714f34e5060954c263160814978076836..194f5002441cb9e471eb08b973d7598210dbe802 100644 (file)
@@ -39,8 +39,12 @@ pub fn main() -> BoxErrorResult<()> {
 fn validate_instances(instances: &[PathBuf], schema: PathBuf, quiet: bool) -> BoxErrorResult<bool> {
     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 {