From 2bdffb0e447e9f8ed3dad7f93dcb4ff7e4fb48a1 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 29 Apr 2024 17:37:54 +0200 Subject: [PATCH] fixup! Catch internal TooSmallFile exception in BuildFileCompound. --- src/fileimpl.cpp | 7 ++++--- test/archive.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fileimpl.cpp b/src/fileimpl.cpp index 80032ff4..84c5f7f2 100644 --- a/src/fileimpl.cpp +++ b/src/fileimpl.cpp @@ -157,9 +157,10 @@ class Grouping GroupId maxGroupId_; }; +class BadSizedFile: public std::exception {}; + } //unnamed namespace -class BadSizedFile: public std::exception {}; ////////////////////////////////////////////////////////////////////// // FileImpl @@ -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."); } } } @@ -192,7 +193,7 @@ class BadSizedFile: public std::exception {}; return std::shared_ptr(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."); } } diff --git a/test/archive.cpp b/test/archive.cpp index 9b2d8290..4a100e41 100644 --- a/test/archive.cpp +++ b/test/archive.cpp @@ -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( @@ -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(