diff --git a/include/fstcpp/fstcpp_assertion.h b/include/fstcpp/fstcpp_assertion.h index e9606f665..8a4d549ad 100644 --- a/include/fstcpp/fstcpp_assertion.h +++ b/include/fstcpp/fstcpp_assertion.h @@ -81,6 +81,12 @@ std::abort(); \ } +#define FST_FAIL_STRING(s) \ + do { \ + std::cerr << (s) << std::endl; \ + std::abort(); \ + } while (0) + // We turn on all DCHECKs to CHECKs temporarily for better safety. #if 1 # define FST_DCHECK(a) FST_CHECK(a) diff --git a/include/fstcpp/fstcpp_variable_info.h b/include/fstcpp/fstcpp_variable_info.h index 470bb8ef1..0074705b1 100644 --- a/include/fstcpp/fstcpp_variable_info.h +++ b/include/fstcpp/fstcpp_variable_info.h @@ -335,10 +335,10 @@ public: // Double variables should not use these array-based emitValueChange overloads. // We implement them to satisfy the VairableInfo::dispatchHelper template instantiation. void emitValueChange(uint64_t, const uint32_t *, EncodingType) { - throw std::runtime_error("emitValueChange(uint32_t*) not supported for Double"); + FST_FAIL_STRING("emitValueChange(uint32_t*) not supported for Double"); } void emitValueChange(uint64_t, const uint64_t *, EncodingType) { - throw std::runtime_error("emitValueChange(uint64_t*) not supported for Double"); + FST_FAIL_STRING("emitValueChange(uint64_t*) not supported for Double"); } void dumpInitialBits(std::vector &buf) const { diff --git a/include/fstcpp/fstcpp_writer.cpp b/include/fstcpp/fstcpp_writer.cpp index 2756e23b9..386a76162 100644 --- a/include/fstcpp/fstcpp_writer.cpp +++ b/include/fstcpp/fstcpp_writer.cpp @@ -193,7 +193,7 @@ Handle Writer::createVar( // (void)type; // (void)svt; // (void)sdt; -// throw std::runtime_error("TODO"); +// FST_FAIL_STRING("TODO"); // return 0; // } // LCOV_EXCL_STOP @@ -353,11 +353,7 @@ void compressUsingZlib( uncompressed_size, level ); - if (z_status != Z_OK) { - throw std::runtime_error( - "Failed to compress data with zlib, error code: " + std::to_string(z_status) - ); - } + FST_CHECK_EQ(z_status, Z_OK); compressed_data.resize(compressed_bound); }