diff --git a/src/storage/backend.rs b/src/storage/backend.rs index ec3aa3da..d3590097 100644 --- a/src/storage/backend.rs +++ b/src/storage/backend.rs @@ -128,7 +128,14 @@ impl StorageBackend { if let Ok(file) = FSFile::open(path) { let mut s = String::new(); file.read_to_string(&mut s); - File::from_parser_result(id, p.read(s)) + let parser_out = p.read(s); + if let Ok((header, data)) = parser_out { + Some(File::from_parser_result(id, header, data)) + } else { + info!("Cannot build File from ID '{}'. Parser Error:\n{}", + id, parser_out.err().unwrap()); + None + } } else { None } diff --git a/src/storage/file.rs b/src/storage/file.rs index 5ef73fb7..c41bdea0 100644 --- a/src/storage/file.rs +++ b/src/storage/file.rs @@ -185,15 +185,11 @@ impl File { } } - pub fn from_parser_result(id: FileID, r: Result<(FileHeaderData, String), ParserError>) -> Option { - if let Ok((header, data)) = r { - Some(File { - header: header, - data: data, - id: id, - }) - } else { - None + pub fn from_parser_result(id: FileID, header: FileHeaderData, data: String) -> File { + File { + header: header, + data: data, + id: id, } }