From b4bdc42b4fd627529e1c4a4636d1631254a2f26e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 13 Aug 2018 19:48:02 -0400 Subject: New exception class QPDFSystemError (fixes #221) --- libqpdf/QUtil.cc | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'libqpdf/QUtil.cc') diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index e2bc0bac..56bac386 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -7,6 +7,7 @@ # include #endif #include +#include #include #include @@ -132,22 +133,7 @@ QUtil::unsigned_char_pointer(char const* str) void QUtil::throw_system_error(std::string const& description) { -#ifdef _MSC_VER - // "94" is mentioned in the MSVC docs, but it's still safe if the - // message is longer. strerror_s is a templated function that - // knows the size of buf and truncates. - char buf[94]; - if (strerror_s(buf, errno) != 0) - { - throw std::runtime_error(description + ": failed with an unknown error"); - } - else - { - throw std::runtime_error(description + ": " + buf); - } -#else - throw std::runtime_error(description + ": " + strerror(errno)); -#endif + throw QPDFSystemError(description, errno); } int -- cgit v1.2.3-54-g00ecf