diff options
author | Eric Toombs <ewtoombs@uwaterloo.ca> | 2009-03-22 22:50:14 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2009-03-22 22:50:14 +0100 |
commit | 441a9cd56935bfe2d8fddc5d3bc2c0104aeffaca (patch) | |
tree | 32bff4a3eeba453d9f08eb16a83fa9f809a4da64 /glib | |
parent | 16af0ced4a0762f2f538135bd8dd72b469f6fdca (diff) |
Improved error reporting of ErrOpenFile errors
See bug #20660 for more information
Diffstat (limited to 'glib')
-rw-r--r-- | glib/poppler-document.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index 387f7d12..3387becb 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <string.h> + #include <goo/GooList.h> #include <splash/SplashBitmap.h> #include <GlobalParams.h> @@ -73,12 +75,18 @@ _poppler_document_new_from_pdfdoc (PDFDoc *newDoc, document = (PopplerDocument *) g_object_new (POPPLER_TYPE_DOCUMENT, NULL, NULL); if (!newDoc->isOk()) { + int fopen_errno; switch (newDoc->getErrorCode()) { case errOpenFile: - g_set_error (error, POPPLER_ERROR, - POPPLER_ERROR_OPEN_FILE, - "Failed to open the PDF file"); + // If there was an error opening the file, count it as a G_FILE_ERROR + // and set the GError parameters accordingly. (this assumes that the + // only way to get an errOpenFile error is if newDoc was created using + // a filename and thus fopen was called, which right now is true. + fopen_errno = newDoc->getFopenErrno(); + g_set_error (error, G_FILE_ERROR, + g_file_error_from_errno (fopen_errno), + strerror(fopen_errno)); break; case errBadCatalog: g_set_error (error, POPPLER_ERROR, |