Skip to content

Commit d7429f7

Browse files
author
David James
committed
fix: return error instead of panic
Note: the choice of `InternalData` may be suboptimal, but it is at least consistent with other places in the code.
1 parent 32059f5 commit d7429f7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/validate.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::cmp::min;
22
use std::io::Error as IoError;
3+
use std::io::ErrorKind::InvalidData;
34
use std::io::{Read, Seek, SeekFrom, Write};
45

56
use crc32fast::Hasher;
@@ -133,7 +134,10 @@ impl<I: Read + Write + Seek> CrcStore<I> {
133134
if remain == 4 {
134135
return self.read_checksum();
135136
} else if remain < 4 {
136-
panic!("internal error");
137+
return Err(IoError::new(
138+
InvalidData,
139+
"internal error: process_segment()",
140+
));
137141
} else {
138142
let body_remain = (remain - 4) as usize;
139143
let to_read = min(body_remain, buf_len);

0 commit comments

Comments
 (0)