Skip to content

Commit

Permalink
update logic for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ayzk committed Dec 9, 2024
1 parent 29234fd commit 10ebed0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions include/SZ3/api/impl/SZDispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ size_t SZ_compress_dispatcher(Config &conf, const T *data, uchar *cmpData, size_
} catch (std::length_error &e) {
if (std::string(e.what()) == SZ_ERROR_COMP_BUFFER_NOT_LARGE_ENOUGH) {
isCmpCapSufficient = false;
printf(
"The buffer for compressed data is not large enough. Ideally, set it as 2X original data size.\n "
"SZ is downgraded to lossless mode.\n");
printf("SZ is downgraded to lossless mode.\n");
} else {
throw;
}
Expand All @@ -65,7 +63,7 @@ size_t SZ_compress_dispatcher(Config &conf, const T *data, uchar *cmpData, size_
if (zstdCmpSize < cmpSize) {
conf.cmprAlgo = ALGO_LOSSLESS;
if (zstdCmpSize > cmpCap) {
fprintf(stderr, SZ_ERROR_COMP_BUFFER_NOT_LARGE_ENOUGH);
fprintf(stderr, "%s\n", SZ_ERROR_COMP_BUFFER_NOT_LARGE_ENOUGH);
throw std::length_error(SZ_ERROR_COMP_BUFFER_NOT_LARGE_ENOUGH);
}
memcpy(cmpData, zstdCmpData, zstdCmpSize);
Expand Down
2 changes: 1 addition & 1 deletion include/SZ3/lossless/Lossless_zstd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Lossless_zstd : public concepts::LosslessInterface {
size_t compress(const uchar *src, size_t srcLen, uchar *dst, size_t dstCap) override {
write(srcLen, dst);
if (dstCap < ZSTD_compressBound(srcLen)) {
fprintf(stderr, SZ_ERROR_COMP_BUFFER_NOT_LARGE_ENOUGH);
fprintf(stderr, "%s\n", SZ_ERROR_COMP_BUFFER_NOT_LARGE_ENOUGH);
throw std::length_error(SZ_ERROR_COMP_BUFFER_NOT_LARGE_ENOUGH);
}
size_t dstLen = ZSTD_compress(dst, dstCap, src, srcLen, compression_level);
Expand Down

0 comments on commit 10ebed0

Please sign in to comment.