Commit d4b10a2041c0b148d2f29f88c28fd82ef6277c7d

Authored by m-holger
1 parent 631c5345

Minor code tweaks: Replace `throw std::runtime_error` with `util::no_ci_rt_error…

…_if` for improved error handling in `QPDFWriter::writeLinearized` and adjust argv parsing in `objects.cc`tests.
libqpdf/QPDFWriter.cc
... ... @@ -2859,16 +2859,17 @@ impl::Writer::writeLinearized()
2859 2859 }
2860 2860 next_objid = part6_first_obj;
2861 2861 enqueuePart(part6);
2862   - if (next_objid != after_part6) {
2863   - throw std::runtime_error("error encountered after writing part 6 of linearized data");
2864   - }
  2862 + util::no_ci_rt_error_if(
  2863 + next_objid != after_part6, "error encountered after writing part 6 of linearized data" //
  2864 + );
2865 2865 next_objid = second_half_first_obj;
2866 2866 enqueuePart(part7);
2867 2867 enqueuePart(part8);
2868 2868 enqueuePart(part9);
2869   - if (next_objid != after_second_half) {
2870   - throw std::runtime_error("error encountered after writing part 9 of cfg.linearized_ data");
2871   - }
  2869 + util::no_ci_rt_error_if(
  2870 + next_objid != after_second_half,
  2871 + "error encountered after writing part 9 of linearized data" //
  2872 + );
2872 2873  
2873 2874 qpdf_offset_t hint_length = 0;
2874 2875 std::string hint_buffer;
... ...
libtests/objects.cc
... ... @@ -356,7 +356,7 @@ main(int argc, char* argv[])
356 356 try {
357 357 int n = QUtil::string_to_int(argv[1]);
358 358 char const* filename1 = argv[2];
359   - char const* arg2 = argv[3];
  359 + char const* arg2 = (argc >= 4) ? argv[3] : "";
360 360 runtest(n, filename1, arg2);
361 361 } catch (std::exception& e) {
362 362 std::cerr << e.what() << '\n';
... ...