summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-27 13:08:41 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-27 13:08:41 -0400
commiteb815bf1c91d74bb03df52f8f7c586d2b2130341 (patch)
treefe961b4df0462e863ee500a81f8766bedd6f7576 /samples
parent8f16b69981730911aa6185451e4899137cc4fca2 (diff)
downloadpdfium-eb815bf1c91d74bb03df52f8f7c586d2b2130341.tar.xz
Merge to XFA: Add context to file load failures in pdfium_test.
Currently if pdfium_test fails to load the document it just says it failed. This CL adds some extra context by looking at the error set by the load and reporting it to the user. TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1413923006 . (cherry picked from commit e6eae266a48cdcfd464f52df68c97183a4f7987a) Review URL: https://codereview.chromium.org/1423123002 .
Diffstat (limited to 'samples')
-rw-r--r--samples/pdfium_test.cc30
1 files changed, 29 insertions, 1 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index c9d84af04d..f1ea429ccc 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -389,7 +389,35 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
}
if (!doc) {
- fprintf(stderr, "Load pdf docs unsuccessful.\n");
+ unsigned long err = FPDF_GetLastError();
+ fprintf(stderr, "Load pdf docs unsuccessful: ");
+ switch (err) {
+ case FPDF_ERR_SUCCESS:
+ fprintf(stderr, "Success");
+ break;
+ case FPDF_ERR_UNKNOWN:
+ fprintf(stderr, "Unknown error");
+ break;
+ case FPDF_ERR_FILE:
+ fprintf(stderr, "File not found or could not be opened");
+ break;
+ case FPDF_ERR_FORMAT:
+ fprintf(stderr, "File not in PDF format or corrupted");
+ break;
+ case FPDF_ERR_PASSWORD:
+ fprintf(stderr, "Password required or incorrect password");
+ break;
+ case FPDF_ERR_SECURITY:
+ fprintf(stderr, "Unsupported security scheme");
+ break;
+ case FPDF_ERR_PAGE:
+ fprintf(stderr, "Page not found or content error");
+ break;
+ default:
+ fprintf(stderr, "Unknown error %ld", err);
+ }
+ fprintf(stderr, ".\n");
+
FPDFAvail_Destroy(pdf_avail);
return;
}