diff --git a/source/adios2/operator/compress/CompressBlosc.cpp b/source/adios2/operator/compress/CompressBlosc.cpp index c7b978a6ac..d8d638360f 100644 --- a/source/adios2/operator/compress/CompressBlosc.cpp +++ b/source/adios2/operator/compress/CompressBlosc.cpp @@ -88,11 +88,11 @@ size_t CompressBlosc::Operate(const char *dataIn, const Dims &blockStart, value, "when setting Blosc clevel parameter\n")); if (compressionLevel < 0 || compressionLevel > 9) { - throw std::invalid_argument( - "ERROR: compression_level must be an " - "integer between 0 (default: no compression) and 9 " - "(more compression, more memory) inclusive, in call to " - "ADIOS2 Blosc Compress\n"); + helper::Log("Operator", "CompressBlosc", "Operate", + "compression_level must be an integer between 0 " + "(no compression) and 9 (more compression, more " + "memory consumption) inclusive", + helper::EXCEPTION); } } else if (key == "doshuffle") @@ -100,11 +100,10 @@ size_t CompressBlosc::Operate(const char *dataIn, const Dims &blockStart, auto itShuffle = m_Shuffles.find(value); if (itShuffle == m_Shuffles.end()) { - throw std::invalid_argument( - "ERROR: invalid shuffle vale " + value + - " must be BLOSC_SHUFFLE, BLOSC_NOSHUFFLE or " - "BLOSC_BITSHUFFLE, " - " in call to ADIOS2 Blosc Compress\n"); + helper::Log("Operator", "CompressBlosc", "Operate", + "Parameter doshuffle must be BLOSC_SHUFFLE, " + "BLOSC_NOSHUFFLE or BLOSC_BITSHUFFLE", + helper::EXCEPTION); } doShuffle = itShuffle->second; } @@ -118,11 +117,10 @@ size_t CompressBlosc::Operate(const char *dataIn, const Dims &blockStart, compressor = value; if (m_Compressors.count(compressor) == 0) { - throw std::invalid_argument( - "ERROR: invalid compressor " + compressor + - " valid values: blosclz (default), lz4, lz4hc, " - "snappy, " - "zlib, or zstd, in call to ADIOS2 Blosc Compression\n"); + helper::Log("Operator", "CompressBlosc", "Operate", + "Parameter compressor must be blosclz (default), " + "lz4, lz4hc, snappy, zlib, or zstd", + helper::EXCEPTION); } } else if (key == "blocksize") @@ -170,10 +168,10 @@ size_t CompressBlosc::Operate(const char *dataIn, const Dims &blockStart, const int result = blosc_set_compressor(compressor.c_str()); if (result == -1) { - throw std::invalid_argument( - "ERROR: invalid compressor " + compressor + - " check if supported by blosc build, in " - "call to ADIOS2 Blosc Compression\n"); + helper::Log("Operator", "CompressBlosc", "Operate", + "blosc library linked does not support compressor " + + compressor, + helper::EXCEPTION); } blosc_set_nthreads(threads); blosc_set_blocksize(blockSize); @@ -245,7 +243,8 @@ size_t CompressBlosc::InverseOperate(const char *bufferIn, const size_t sizeIn, } else { - throw("unknown blosc buffer version"); + helper::Log("Operator", "CompressBlosc", "InverseOperate", + "corrupted compressed buffer", helper::EXCEPTION); } return 0; @@ -273,7 +272,9 @@ size_t CompressBlosc::DecompressV1(const char *bufferIn, const size_t sizeIn, if (sizeIn - bufferInOffset < sizeof(DataHeader)) { - throw("corrupted blosc buffer header." + m_VersionInfo + "\n"); + helper::Log("Operator", "CompressBlosc", "InverseOperate", + "corrupted compressed buffer." + m_VersionInfo, + helper::EXCEPTION); } const bool isChunked = reinterpret_cast(bufferIn + bufferInOffset) @@ -294,7 +295,9 @@ size_t CompressBlosc::DecompressV1(const char *bufferIn, const size_t sizeIn, } if (decompressedSize != sizeOut) { - throw("corrupted blosc buffer." + m_VersionInfo + "\n"); + helper::Log("Operator", "CompressBlosc", "InverseOperate", + "corrupted compressed buffer." + m_VersionInfo, + helper::EXCEPTION); } return sizeOut; } @@ -359,10 +362,11 @@ size_t CompressBlosc::DecompressChunkedFormat(const char *bufferIn, currentOutputSize += static_cast(decompressdSize); else { - throw std::runtime_error( - "ERROR: ADIOS2 Blosc Decompress failed. Decompressed chunk " - "results in zero decompressed bytes." + - m_VersionInfo + "\n"); + helper::Log("Operator", "CompressBlosc", + "DecompressChunkedFormat", + "blosc decompress failed with zero buffer size. " + + m_VersionInfo, + helper::EXCEPTION); } inputOffset += static_cast(max_inputDataSize); } diff --git a/source/adios2/operator/compress/CompressSZ.cpp b/source/adios2/operator/compress/CompressSZ.cpp index 6dc5ab7926..1ac009501b 100644 --- a/source/adios2/operator/compress/CompressSZ.cpp +++ b/source/adios2/operator/compress/CompressSZ.cpp @@ -129,9 +129,10 @@ size_t CompressSZ::Operate(const char *dataIn, const Dims &blockStart, } else { - throw std::invalid_argument( - "ERROR: ADIOS2 operator unknown SZ parameter szMode: " + - it->second + "\n"); + helper::Log("Operator", "CompressSZ", "Operate", + "Parameter szMode must be SZ_BEST_SPEED, " + "SZ_BEST_COMPRESSION or SZ_DEFAULT_COMPRESSION", + helper::EXCEPTION); } sz.szMode = szMode; } @@ -164,10 +165,10 @@ size_t CompressSZ::Operate(const char *dataIn, const Dims &blockStart, } else { - throw std::invalid_argument("ERROR: ADIOS2 operator " - "unknown SZ parameter " - "errorBoundMode: " + - it->second + "\n"); + helper::Log("Operator", "CompressSZ", "Operate", + "Parameter errorBoundMode must be ABS, REL, " + "ABS_AND_REL, ABS_OR_REL or PW_REL", + helper::EXCEPTION); } sz.errorBoundMode = errorBoundMode; } @@ -190,24 +191,24 @@ size_t CompressSZ::Operate(const char *dataIn, const Dims &blockStart, else if (it->first == "pwr_type") { int pwr_type = SZ_PWR_MIN_TYPE; - if ((it->first == "MIN") || (it->first == "SZ_PWR_MIN_TYPE")) + if ((it->second == "MIN") || (it->second == "SZ_PWR_MIN_TYPE")) { pwr_type = SZ_PWR_MIN_TYPE; } - else if ((it->first == "AVG") || (it->first == "SZ_PWR_AVG_TYPE")) + else if ((it->second == "AVG") || (it->second == "SZ_PWR_AVG_TYPE")) { pwr_type = SZ_PWR_AVG_TYPE; } - else if ((it->first == "MAX") || (it->first == "SZ_PWR_MAX_TYPE")) + else if ((it->second == "MAX") || (it->second == "SZ_PWR_MAX_TYPE")) { pwr_type = SZ_PWR_MAX_TYPE; } else { - throw std::invalid_argument("ERROR: ADIOS2 operator " - "unknown SZ parameter " - "pwr_type: " + - it->second + "\n"); + helper::Log("Operator", "CompressSZ", "Operate", + "Parameter pwr_type must be MIN, SZ_PWR_MIN_TYPE, " + "AVG, SZ_PWR_AVG_TYPE, MAX or SZ_PWR_MAX_TYPE", + helper::EXCEPTION); } sz.pwr_type = pwr_type; } @@ -265,9 +266,9 @@ size_t CompressSZ::Operate(const char *dataIn, const Dims &blockStart, } else { - throw std::invalid_argument("ERROR: ADIOS2 SZ Compression only support " - "double or float, type: " + - ToString(varType) + " is unsupported\n"); + helper::Log("Operator", "CompressSZ", "Operate", + "SZ compressor only support float or double types", + helper::EXCEPTION); } convertedDims = ConvertDims(blockCount, varType, 5, true, 0); @@ -309,7 +310,10 @@ size_t CompressSZ::InverseOperate(const char *bufferIn, const size_t sizeIn, } else { - throw("unknown sz buffer version"); + helper::Log("Operator", "CompressSZ", "InverseOperate", + "unknown sz buffer version, probably caused by corrupted " + "compressed buffer", + helper::EXCEPTION); } return 0; @@ -372,8 +376,9 @@ size_t CompressSZ::DecompressV1(const char *bufferIn, const size_t sizeIn, } else { - throw std::runtime_error( - "ERROR: data type must be either double or float in SZ\n"); + helper::Log("Operator", "CompressSZ", "DecompressV1", + "SZ compressor only support float or double types", + helper::EXCEPTION); } const size_t dataSizeBytes = @@ -388,8 +393,9 @@ size_t CompressSZ::DecompressV1(const char *bufferIn, const size_t sizeIn, if (result == nullptr) { - throw std::runtime_error("ERROR: SZ_decompress failed." + - m_VersionInfo + "\n"); + helper::Log("Operator", "CompressSZ", "DecompressV1", + "decompression failed. " + m_VersionInfo, + helper::EXCEPTION); } std::memcpy(dataOut, result, dataSizeBytes); free(result); @@ -440,8 +446,9 @@ size_t CompressSZ::DecompressV2(const char *bufferIn, const size_t sizeIn, } else { - throw std::runtime_error( - "ERROR: data type must be either double or float in SZ\n"); + helper::Log("Operator", "CompressSZ", "DecompressV2", + "SZ compressor only support float or double types", + helper::EXCEPTION); } const size_t dataSizeBytes = helper::GetTotalSize(blockCount, dataTypeSize); @@ -458,8 +465,9 @@ size_t CompressSZ::DecompressV2(const char *bufferIn, const size_t sizeIn, if (result == nullptr) { - throw std::runtime_error("ERROR: SZ_decompress failed." + - m_VersionInfo + "\n"); + helper::Log("Operator", "CompressSZ", "DecompressV2", + "decompression failed. " + m_VersionInfo, + helper::EXCEPTION); } std::memcpy(dataOut, result, dataSizeBytes); free(result);