From f3d7c26de1f575a14017a161ad1fdd2b93385e03 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 26 Sep 2009 18:36:04 +0000 Subject: removed qexc; non-compatible ABI change git-svn-id: svn+q:///qpdf/trunk@709 71b93d88-0707-0410-a8cf-f5a4172ac649 --- libqpdf/QUtil.cc | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'libqpdf/QUtil.cc') diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 0d0b4667..1b9ca924 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -1,4 +1,4 @@ - +#include #include #include #include @@ -25,9 +25,9 @@ QUtil::int_to_string(int num, int fullpad) // -2 or -1 to leave space for the possible negative sign and for NUL... if (abs(fullpad) > (int)sizeof(t) - ((num < 0)?2:1)) { - throw QEXC::Internal("Util::int_to_string has been called with " - "a padding value greater than its internal " - "limit"); + throw std::logic_error("Util::int_to_string has been called with " + "a padding value greater than its internal " + "limit"); } if (fullpad) @@ -62,9 +62,9 @@ QUtil::double_to_string(double num, int decimal_places) // always pass in those cases. if (decimal_places + 1 + (int)lhs.length() > (int)sizeof(t) - 1) { - throw QEXC::Internal("Util::double_to_string has been called with " - "a number and a decimal places specification " - "that would break an internal limit"); + throw std::logic_error("Util::double_to_string has been called with " + "a number and a decimal places specification " + "that would break an internal limit"); } if (decimal_places) @@ -78,24 +78,31 @@ QUtil::double_to_string(double num, int decimal_places) return std::string(t); } +DLL_EXPORT +void +QUtil::throw_system_error(std::string const& description) +{ + throw std::runtime_error(description + ": " + strerror(errno)); +} + DLL_EXPORT int -QUtil::os_wrapper(std::string const& description, int status) throw (QEXC::System) +QUtil::os_wrapper(std::string const& description, int status) { if (status == -1) { - throw QEXC::System(description, errno); + throw_system_error(description); } return status; } DLL_EXPORT FILE* -QUtil::fopen_wrapper(std::string const& description, FILE* f) throw (QEXC::System) +QUtil::fopen_wrapper(std::string const& description, FILE* f) { if (f == 0) { - throw QEXC::System(description, errno); + throw_system_error(description); } return f; } @@ -240,7 +247,7 @@ QUtil::toUTF8(unsigned long uval) if (uval > 0x7fffffff) { - throw QEXC::General("bounds error in QUtil::toUTF8"); + throw std::runtime_error("bounds error in QUtil::toUTF8"); } else if (uval < 128) { @@ -267,7 +274,7 @@ QUtil::toUTF8(unsigned long uval) --cur_byte; if (cur_byte < bytes) { - throw QEXC::Internal("QUtil::toUTF8: overflow error"); + throw std::logic_error("QUtil::toUTF8: overflow error"); } } // If maxval is k bits long, the high (7 - k) bits of the -- cgit v1.2.3-70-g09d2