Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: samples/pdfium_test.cc

Issue 1413923006: Add context to file load failures in pdfium_test. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> 5 #include <limits.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 if (FPDFAvail_IsLinearized(pdf_avail)) { 384 if (FPDFAvail_IsLinearized(pdf_avail)) {
385 fprintf(stderr, "Linearized path...\n"); 385 fprintf(stderr, "Linearized path...\n");
386 doc = FPDFAvail_GetDocument(pdf_avail, nullptr); 386 doc = FPDFAvail_GetDocument(pdf_avail, nullptr);
387 } else { 387 } else {
388 fprintf(stderr, "Non-linearized path...\n"); 388 fprintf(stderr, "Non-linearized path...\n");
389 doc = FPDF_LoadCustomDocument(&file_access, nullptr); 389 doc = FPDF_LoadCustomDocument(&file_access, nullptr);
390 } 390 }
391 391
392 if (!doc) { 392 if (!doc) {
393 fprintf(stderr, "Load pdf docs unsuccessful.\n"); 393 unsigned long err = FPDF_GetLastError();
394 fprintf(stderr, "Load pdf docs unsuccessful: ");
395 switch (err) {
396 case FPDF_ERR_SUCCESS:
397 fprintf(stderr, "Success");
398 break;
399 case FPDF_ERR_UNKNOWN:
400 fprintf(stderr, "Unknown error");
401 break;
402 case FPDF_ERR_FILE:
403 fprintf(stderr, "File not found or could not be opened");
404 break;
405 case FPDF_ERR_FORMAT:
406 fprintf(stderr, "File not in PDF format or corrupted");
407 break;
408 case FPDF_ERR_PASSWORD:
409 fprintf(stderr, "Password required or incorrect password");
410 break;
411 case FPDF_ERR_SECURITY:
412 fprintf(stderr, "Unsupported security scheme");
413 break;
414 case FPDF_ERR_PAGE:
415 fprintf(stderr, "Page not found or content error");
416 break;
417 default:
418 fprintf(stderr, "Unknown error %ld", err);
419 }
420 fprintf(stderr, ".\n");
421
394 FPDFAvail_Destroy(pdf_avail); 422 FPDFAvail_Destroy(pdf_avail);
395 return; 423 return;
396 } 424 }
397 425
398 (void)FPDF_GetDocPermissions(doc); 426 (void)FPDF_GetDocPermissions(doc);
399 (void)FPDFAvail_IsFormAvail(pdf_avail, &hints); 427 (void)FPDFAvail_IsFormAvail(pdf_avail, &hints);
400 428
401 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); 429 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks);
402 FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD); 430 FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD);
403 FPDF_SetFormFieldHighlightAlpha(form, 100); 431 FPDF_SetFormFieldHighlightAlpha(form, 100);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 } 581 }
554 582
555 FPDF_DestroyLibrary(); 583 FPDF_DestroyLibrary();
556 #ifdef PDF_ENABLE_V8 584 #ifdef PDF_ENABLE_V8
557 v8::V8::ShutdownPlatform(); 585 v8::V8::ShutdownPlatform();
558 delete platform; 586 delete platform;
559 #endif // PDF_ENABLE_V8 587 #endif // PDF_ENABLE_V8
560 588
561 return 0; 589 return 0;
562 } 590 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698