Skip to content

Commit

Permalink
Convert some cases of logic_error to runtime_error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jberkenbilt committed Jun 25, 2019
1 parent 201e879 commit 4db1de9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions libqpdf/QPDFObjectHandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,7 @@ QPDFObjectHandle::warnIfPossible(std::string const& warning,
}
else if (throw_if_no_description)
{
throw std::logic_error(warning);
throw std::runtime_error(warning);
}
}

Expand All @@ -2530,9 +2530,9 @@ QPDFObjectHandle::assertType(char const* type_name, bool istype)
{
if (! istype)
{
throw std::logic_error(std::string("operation for ") + type_name +
" attempted on object of type " +
getTypeName());
throw std::runtime_error(std::string("operation for ") + type_name +
" attempted on object of type " +
getTypeName());
}
}

Expand Down Expand Up @@ -2670,7 +2670,7 @@ QPDFObjectHandle::assertPageObject()
{
if (! isPageObject())
{
throw std::logic_error("page operation called on non-Page object");
throw std::runtime_error("page operation called on non-Page object");
}
}

Expand Down
2 changes: 1 addition & 1 deletion libqpdf/QPDF_pages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ QPDF::flattenPagesTree()
// /Count has not changed
if (pages.getKey("/Count").getUIntValue() != len)
{
throw std::logic_error("/Count is wrong after flattening pages tree");
throw std::runtime_error("/Count is wrong after flattening pages tree");
}
}

Expand Down

0 comments on commit 4db1de9

Please sign in to comment.