Commit 4db1de97cea9dfab3f3abe43766053ba0d594610

Authored by Jay Berkenbilt
1 parent 201e8798

Convert some cases of logic_error to runtime_error

There were a few cases that could be caused by invalid input rather
than bugs in the code which were throwing logic_error instead of
runtime_error.
libqpdf/QPDFObjectHandle.cc
... ... @@ -2515,7 +2515,7 @@ QPDFObjectHandle::warnIfPossible(std::string const& warning,
2515 2515 }
2516 2516 else if (throw_if_no_description)
2517 2517 {
2518   - throw std::logic_error(warning);
  2518 + throw std::runtime_error(warning);
2519 2519 }
2520 2520 }
2521 2521  
... ... @@ -2530,9 +2530,9 @@ QPDFObjectHandle::assertType(char const* type_name, bool istype)
2530 2530 {
2531 2531 if (! istype)
2532 2532 {
2533   - throw std::logic_error(std::string("operation for ") + type_name +
2534   - " attempted on object of type " +
2535   - getTypeName());
  2533 + throw std::runtime_error(std::string("operation for ") + type_name +
  2534 + " attempted on object of type " +
  2535 + getTypeName());
2536 2536 }
2537 2537 }
2538 2538  
... ... @@ -2670,7 +2670,7 @@ QPDFObjectHandle::assertPageObject()
2670 2670 {
2671 2671 if (! isPageObject())
2672 2672 {
2673   - throw std::logic_error("page operation called on non-Page object");
  2673 + throw std::runtime_error("page operation called on non-Page object");
2674 2674 }
2675 2675 }
2676 2676  
... ...
libqpdf/QPDF_pages.cc
... ... @@ -166,7 +166,7 @@ QPDF::flattenPagesTree()
166 166 // /Count has not changed
167 167 if (pages.getKey("/Count").getUIntValue() != len)
168 168 {
169   - throw std::logic_error("/Count is wrong after flattening pages tree");
  169 + throw std::runtime_error("/Count is wrong after flattening pages tree");
170 170 }
171 171 }
172 172  
... ...