Skip to content

Commit

Permalink
fixup! Catch internal TooSmallFile exception in BuildFileCompound.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed Apr 29, 2024
1 parent c71c023 commit 2bdffb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/fileimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ class Grouping
GroupId maxGroupId_;
};

class BadSizedFile: public std::exception {};

} //unnamed namespace

class BadSizedFile: public std::exception {};

//////////////////////////////////////////////////////////////////////
// FileImpl
Expand All @@ -180,7 +181,7 @@ class BadSizedFile: public std::exception {};
fname.resize(fname.size()-2);
} else {
// We have found a (not split) file but it is too small.
throw ZimFileFormatError("Zim file(s) is too small.");
throw ZimFileFormatError("Zim file(s) is of bad size or corrupted.");
}
}
}
Expand All @@ -192,7 +193,7 @@ class BadSizedFile: public std::exception {};
return std::shared_ptr<FileImpl>(new FileImpl(fileCompound));
} catch (BadSizedFile& e) {
// BadSizedFile is internal error.
throw ZimFileFormatError("Zim file(s) is too small.");
throw ZimFileFormatError("Zim file(s) is of bad size or corrupted.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ TEST(ZimArchive, validate)

TEST_BROKEN_ZIM_NAME(
"invalid.smaller_than_header.zim",
"Zim file(s) is too small.\n"
"Zim file(s) is of bad size or corrupted.\n"
);

TEST_BROKEN_ZIM_NAME(
Expand Down Expand Up @@ -459,7 +459,7 @@ TEST(ZimArchive, validate)

TEST_BROKEN_ZIM_NAME(
"invalid.invalid_checksumpos.zim",
"Zim file(s) is too small.\n"
"Zim file(s) is of bad size or corrupted.\n"
);

TEST_BROKEN_ZIM_NAME(
Expand Down

0 comments on commit 2bdffb0

Please sign in to comment.