From 7f5d78c2d15565dd8a2357268f187045eb3ebc27 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 23 Oct 2009 15:27:30 +0000 Subject: improve C error handling interface git-svn-id: svn+q:///qpdf/trunk@884 71b93d88-0707-0410-a8cf-f5a4172ac649 --- include/qpdf/Constants.h | 3 +-- include/qpdf/qpdf-c.h | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h index eb872788..d74cace3 100644 --- a/include/qpdf/Constants.h +++ b/include/qpdf/Constants.h @@ -17,8 +17,7 @@ enum qpdf_error_code_e { - qpdf_e_success = 0, - qpdf_e_internal, /* logic/programming error -- indicates bug */ + qpdf_e_internal = 1, /* 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 */ diff --git a/include/qpdf/qpdf-c.h b/include/qpdf/qpdf-c.h index 0980f1f7..492a72ba 100644 --- a/include/qpdf/qpdf-c.h +++ b/include/qpdf/qpdf-c.h @@ -106,9 +106,18 @@ extern "C" { /* ERROR REPORTING */ + /* Returns 1 if there is an error condition. The error condition + * can be retrieved by a single call to qpdf_get_error. + */ + QPDF_DLL + QPDF_BOOL qpdf_has_error(qpdf_data qpdf); + /* Returns the error condition, if any. The return value is a - * pointer to data that will become invalid the next time an error - * occurs or after this function is called gain. + * pointer to data that will become invalid after the next call to + * this function, qpdf_next_warning, or qpdf_destroy. After this + * function is called, qpdf_has_error will return QPDF_FALSE until + * the next error condition occurs. If there is no error + * condition, this function returns a null pointer. */ QPDF_DLL qpdf_error qpdf_get_error(qpdf_data qpdf); @@ -133,7 +142,8 @@ 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. */ + * error; see QPDFExc.hh for details. It is invalid for e to be a + * null pointer for any of these calls. */ QPDF_DLL enum qpdf_error_code_e qpdf_get_error_code(qpdf_data q, qpdf_error e); QPDF_DLL -- cgit v1.2.3-54-g00ecf