1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 18:24:05 +02:00

improved error handling

This commit is contained in:
Robin Appelman 2019-08-10 23:01:33 +02:00
commit e005f35f73
2 changed files with 4 additions and 2 deletions

View file

@ -179,14 +179,14 @@ fn parse_string_table_list(
stream: &mut Stream, stream: &mut Stream,
table_meta: &StringTableMeta, table_meta: &StringTableMeta,
entry_count: u16, entry_count: u16,
) -> ReadResult<Vec<StringTableEntry>> { ) -> Result<Vec<StringTableEntry>> {
let mut entries = Vec::with_capacity(entry_count as usize); let mut entries = Vec::with_capacity(entry_count as usize);
let mut history: Vec<Option<String>> = Vec::new(); let mut history: Vec<Option<String>> = Vec::new();
for _ in 0..entry_count { for _ in 0..entry_count {
if !stream.read::<bool>()? { if !stream.read::<bool>()? {
panic!("there should be no holes when reading CreateStringTable message"); return Err(ParseError::InvalidDemo("there should be no holes when reading CreateStringTable message".to_string()));
}; };
let entry = read_table_entry(stream, table_meta, &history)?; let entry = read_table_entry(stream, table_meta, &history)?;

View file

@ -51,6 +51,8 @@ pub enum ParseError {
/// Actual decompressed size /// Actual decompressed size
size: u32, size: u32,
}, },
/// Misc malformed demo error
InvalidDemo(String)
} }
impl From<ReadError> for ParseError { impl From<ReadError> for ParseError {