mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-22 14:48:28 +00:00
more tweaking of C error interface
git-svn-id: svn+q:///qpdf/trunk@894 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
parent
cfc1f6fcac
commit
b1702fb16c
@ -17,7 +17,8 @@
|
||||
|
||||
enum qpdf_error_code_e
|
||||
{
|
||||
qpdf_e_internal = 1, /* logic/programming error -- indicates bug */
|
||||
qpdf_e_success = 0,
|
||||
qpdf_e_internal, /* logic/programming error -- indicates bug */
|
||||
qpdf_e_system, /* I/O error, memory error, etc. */
|
||||
qpdf_e_unsupported, /* PDF feature not (yet) supported by qpdf */
|
||||
qpdf_e_password, /* incorrect password for encrypted file */
|
||||
|
@ -142,8 +142,7 @@ extern "C" {
|
||||
char const* qpdf_get_error_full_text(qpdf_data q, qpdf_error e);
|
||||
|
||||
/* Use these functions to extract individual fields from the
|
||||
* error; see QPDFExc.hh for details. It is invalid for e to be a
|
||||
* null pointer for any of these calls. */
|
||||
* error; see QPDFExc.hh for details. */
|
||||
QPDF_DLL
|
||||
enum qpdf_error_code_e qpdf_get_error_code(qpdf_data q, qpdf_error e);
|
||||
QPDF_DLL
|
||||
|
@ -166,26 +166,46 @@ qpdf_error qpdf_next_warning(qpdf_data qpdf)
|
||||
|
||||
char const* qpdf_get_error_full_text(qpdf_data qpdf, qpdf_error e)
|
||||
{
|
||||
if (e == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return e->exc.getPointer()->what();
|
||||
}
|
||||
|
||||
enum qpdf_error_code_e qpdf_get_error_code(qpdf_data qpdf, qpdf_error e)
|
||||
{
|
||||
if (e == 0)
|
||||
{
|
||||
return qpdf_e_success;
|
||||
}
|
||||
return e->exc.getPointer()->getErrorCode();
|
||||
}
|
||||
|
||||
char const* qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e)
|
||||
{
|
||||
if (e == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return e->exc.getPointer()->getFilename().c_str();
|
||||
}
|
||||
|
||||
unsigned long qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e)
|
||||
{
|
||||
if (e == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return e->exc.getPointer()->getFilePosition();
|
||||
}
|
||||
|
||||
char const* qpdf_get_error_message_detail(qpdf_data qpdf, qpdf_error e)
|
||||
{
|
||||
if (e == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return e->exc.getPointer()->getMessageDetail().c_str();
|
||||
}
|
||||
|
||||
|
@ -18,15 +18,24 @@ static void report_errors()
|
||||
printf(" pos : %ld\n", qpdf_get_error_file_position(qpdf, e));
|
||||
printf(" text: %s\n", qpdf_get_error_message_detail(qpdf, e));
|
||||
}
|
||||
e = qpdf_get_error(qpdf);
|
||||
if (qpdf_has_error(qpdf))
|
||||
{
|
||||
e = qpdf_get_error(qpdf);
|
||||
printf("error: %s\n", qpdf_get_error_full_text(qpdf, e));
|
||||
printf(" code: %d\n", qpdf_get_error_code(qpdf, e));
|
||||
printf(" file: %s\n", qpdf_get_error_filename(qpdf, e));
|
||||
printf(" pos : %ld\n", qpdf_get_error_file_position(qpdf, e));
|
||||
printf(" text: %s\n", qpdf_get_error_message_detail(qpdf, e));
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(e == 0);
|
||||
assert(qpdf_get_error_code(qpdf, e) == qpdf_e_success);
|
||||
(void)qpdf_get_error_full_text(qpdf, e);
|
||||
(void)qpdf_get_error_filename(qpdf, e);
|
||||
(void)qpdf_get_error_file_position(qpdf, e);
|
||||
(void)qpdf_get_error_message_detail(qpdf, e);
|
||||
}
|
||||
}
|
||||
|
||||
static void test01(char const* infile,
|
||||
|
Loading…
x
Reference in New Issue
Block a user