aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-09-09 13:49:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-09-09 13:49:46 +0200
commit2de164c50981044be723629d4484a79639e92cf0 (patch)
tree0bf9badcfc770cadca9a868994588c84c1d8a8c5
parent432a30e7e896d3049d5c2bde40604795f57b3441 (diff)
Improve LZ4 exception descriptions
-rw-r--r--libbutl/lz4-stream.cxx4
-rw-r--r--libbutl/lz4.cxx34
-rw-r--r--tests/lz4/testscript6
3 files changed, 22 insertions, 22 deletions
diff --git a/libbutl/lz4-stream.cxx b/libbutl/lz4-stream.cxx
index 43b0250..9d0ac99 100644
--- a/libbutl/lz4-stream.cxx
+++ b/libbutl/lz4-stream.cxx
@@ -126,7 +126,7 @@ namespace butl
d_.in += p.first;
if (p.second && d_.in != h_)
- throw invalid_argument ("incomplete compressed content");
+ throw invalid_argument ("incomplete LZ4 compressed content");
}
h_ = d_.next (); // Clears d_.in.
@@ -149,7 +149,7 @@ namespace butl
(!is_->eof () &&
is_->good () &&
is_->peek () != istream::traits_type::eof ()))
- throw invalid_argument ("junk after compressed content");
+ throw invalid_argument ("junk after LZ4 compressed content");
}
return r;
diff --git a/libbutl/lz4.cxx b/libbutl/lz4.cxx
index 9d15203..a627b06 100644
--- a/libbutl/lz4.cxx
+++ b/libbutl/lz4.cxx
@@ -54,22 +54,22 @@ namespace butl
switch (c)
{
- case LZ4F_ERROR_GENERIC: throw i ("generic error");
- case LZ4F_ERROR_maxBlockSize_invalid: throw i ("invalid block size");
- case LZ4F_ERROR_blockMode_invalid: throw i ("invalid block mode");
- case LZ4F_ERROR_contentChecksumFlag_invalid: throw i ("invalid content checksum flag");
- case LZ4F_ERROR_compressionLevel_invalid: throw i ("invalid compression level");
- case LZ4F_ERROR_headerVersion_wrong: throw i ("wrong header version");
- case LZ4F_ERROR_blockChecksum_invalid: throw i ("invalid block checksum");
- case LZ4F_ERROR_reservedFlag_set: throw i ("reserved flag set");
- case LZ4F_ERROR_srcSize_tooLarge: throw i ("input too large");
- case LZ4F_ERROR_dstMaxSize_tooSmall: throw i ("output too small");
- case LZ4F_ERROR_frameHeader_incomplete: throw i ("incomplete frame header");
- case LZ4F_ERROR_frameType_unknown: throw i ("unknown frame type");
- case LZ4F_ERROR_frameSize_wrong: throw i ("wrong frame size");
- case LZ4F_ERROR_decompressionFailed: throw i ("invalid compressed content");
- case LZ4F_ERROR_headerChecksum_invalid: throw i ("invalid header checksum");
- case LZ4F_ERROR_contentChecksum_invalid: throw i ("invalid content checksum");
+ case LZ4F_ERROR_GENERIC: throw i ("generic LZ4 error");
+ case LZ4F_ERROR_maxBlockSize_invalid: throw i ("invalid LZ4 block size");
+ case LZ4F_ERROR_blockMode_invalid: throw i ("invalid LZ4 block mode");
+ case LZ4F_ERROR_contentChecksumFlag_invalid: throw i ("invalid LZ4 content checksum flag");
+ case LZ4F_ERROR_compressionLevel_invalid: throw i ("invalid LZ4 compression level");
+ case LZ4F_ERROR_headerVersion_wrong: throw i ("wrong LZ4 header version");
+ case LZ4F_ERROR_blockChecksum_invalid: throw i ("invalid LZ4 block checksum");
+ case LZ4F_ERROR_reservedFlag_set: throw i ("reserved LZ4 flag set");
+ case LZ4F_ERROR_srcSize_tooLarge: throw i ("LZ4 input too large");
+ case LZ4F_ERROR_dstMaxSize_tooSmall: throw i ("LZ4 output too small");
+ case LZ4F_ERROR_frameHeader_incomplete: throw i ("incomplete LZ4 frame header");
+ case LZ4F_ERROR_frameType_unknown: throw i ("unknown LZ4 frame type");
+ case LZ4F_ERROR_frameSize_wrong: throw i ("wrong LZ4 frame size");
+ case LZ4F_ERROR_decompressionFailed: throw i ("invalid LZ4 compressed content");
+ case LZ4F_ERROR_headerChecksum_invalid: throw i ("invalid LZ4 header checksum");
+ case LZ4F_ERROR_contentChecksum_invalid: throw i ("invalid LZ4 content checksum");
case LZ4F_ERROR_allocation_failed: throw bad_alloc ();
@@ -511,7 +511,7 @@ namespace butl
if (h != 0)
{
if (eof)
- throw invalid_argument ("incomplete compressed content");
+ throw invalid_argument ("incomplete LZ4 compressed content");
d.in = read (d.ib, h);
}
diff --git a/tests/lz4/testscript b/tests/lz4/testscript
index 0cd5cba..b064cff 100644
--- a/tests/lz4/testscript
+++ b/tests/lz4/testscript
@@ -69,17 +69,17 @@ diff ../512kb 512kb
: truncated-header6
:
$* -d $src_base/truncated-header6.lz4 out &out 2>>EOE !=0
-incomplete frame header
+incomplete LZ4 frame header
EOE
: truncated-header12
:
$* -d $src_base/truncated-header12.lz4 out &out 2>>EOE !=0
-incomplete frame header
+incomplete LZ4 frame header
EOE
: truncated-content
:
$* -d $src_base/truncated-content.lz4 out &out 2>>EOE !=0
-incomplete compressed content
+incomplete LZ4 compressed content
EOE