Error Codes

<< Click to Display Table of Contents >>

Navigation:  Error Handling >

Error Codes


 

pdf-xchange-editor-simple-sdk_100x100 Error Codes

 


 

Functions return an HRESULT value in most cases. This provides a simple means to determine the success/failure of a function call.

 

If the most significant bit or result is set to 1 then the specified error occurred. Any other result means the function was successful. The following macros for C/C++ apply these checks:

 

#define IS_DS_SUCCESSFUL(x)          (((x) & 0x80000000) == 0)

#define IS_DS_FAILED(x)              (((x) & 0x80000000) != 0)

 

Note: it is strongly recommended to use the same macros consistently in order to establish the success of function calls. A simple comparison with zero will often result in unreliable data, as detailed in the example below.

 

Please note that these macros are case-sensitive.

 

Functions may return warning codes that are neither equal to zero nor negative. Usually this means that the function was successful and is providing additional information about the call, for example that a default value was returned. See Functions for further information.

 

The IS_DS_WARNING macros can be used to determine if the return value generates a warning. The following code can be used to check for the error status of the PXCV_CheckPassword function:

 

HRESULT hr = PXCV_CheckPassword(docpasswordlen);

 

    if (IS_DS_FAILED(hr))

    {

        // An error occurred!

        // Manage the error accordingly to provide an orderly exit from the function call

        ...

    }

    else

    {

        // 'hr' contains a value that indicates whether the password supplied was owner or user

        ...

    }

 

The following code is an example of how error-checking should not be performed:

 

HRESULT hr = PXCV_CheckPassword(docpasswordlen);

 

    if (hr == 0)

    {

        // treat as success

        ...

 

        (this is not true as a positive return value was received!)

        ...

    }

    else

    {

        // treat as error

        (Incorrect as the return value has not been adequately identified and this is unreliable!)

        ...

    }

 

The most common error codes are listed in the table below, but it should be noted that functions may return other error codes. There are three further functions available for dealing with errors that may provide additional information: PXCV_Err_FormatSeverity, PXCV_Err_FormatFacility and PXCV_Err_FormatErrorCode. A code example is provided below the table. Please note that this function will provide information about all possible error codes.

 

Possible error values of PDF parser/structure:

 

 

Constant

 

 

Value

 

 

Description

 

 

S_ERR_NOTIMPLEMENTED

 

 

0x820f04b0

 

 

The function is not implemented.

 

 

PS_ERR_INVALID_ARG

         

 

0x820f0001

 

 

The argument is invalid.

 

 

PS_ERR_MEMALLOC

         

 

0x820f03e8

 

 

There is insufficient memory to perform the function.

 

 

PS_ERR_USER_BREAK

 

 

0x820f01f4

 

 

The user aborted the operation.

 

 

PS_ERR_INTERNAL

 

 

0x820f0011

 

 

There are an internal error.

 

 

PS_ERR_INVALID_FILE_FORMAT

 

 

0x820f0002

 

 

The file format is invalid.

 

 

PS_ERR_REQUIRED_PROP_NOT_SET

 

 

0x820f2716

 

 

A required property is not set.

 

 

PS_ERR_INVALID_PROP_TYPE

 

 

0x820f2717

 

 

The property type is invalid.

 

 

PS_ERR_INVALID_PROP_VALUE

 

 

0x820f2718

 

 

The property value is invalid.

 

 

PS_ERR_INVALID_OBJECT_NUM

 

 

0x820f2719

 

 

The object number is invalid.

 

 

PS_ERR_INVALID_PS_OPERATOR

 

 

0x820f271c

 

 

The PS operator is invalid.

 

 

PS_ERR_UNKNOWN_OPERATOR

         

 

0x820f2787

 

 

The operator is unknown.

 

 

PS_ERR_INVALID_CONTENT_STATE

 

 

0x820f2788

 

 

The content state is invalid.

 

 

PS_ERR_NoPassword

 

 

0x820f27a8

 

 

There is no password.

 

 

PS_ERR_UnknowCryptFlt

 

 

0x820f27a9

 

 

There is an unknown crypt filter.

 

 

PS_ERR_WrongPassword

 

 

0x820f27aa

 

 

The password provided is incorrect.

 

 

PS_ERR_InvlaidObjStruct

 

 

0x820f27ab

 

 

The object structure is invalid.

 

 

PS_ERR_WrongEncryptDict

 

 

0x820f27ac

 

 

The encryption dictionary is invalid.

 

 

PS_ERR_DocEncrypted

 

 

0x820f27ad

 

 

The document is encrypted.

 

 

PS_ERR_DocNOTEncrypted

 

 

0x820f27ae

 

 

The document not encrypted.

 

 

PS_ERR_WrongObjStream

 

 

0x820f27af

 

 

The object stream is invalid.

 

 

PS_ERR_WrongTrailer

 

 

0x820f27b0

 

 

The document trailer is invalid.

 

 

PS_ERR_WrongXRef

 

 

0x820f27b1

 

 

The xref table is invalid.

 

 

PS_ERR_WrongDecodeParms

 

 

0x820f27b2

 

 

There is at least one invalid decode parameter.

 

 

PS_ERR_XRefNotFounded

 

 

0x820f27b3

 

 

The xref table was not found.

 

 

PS_ERR_DocAlreadyRead

 

 

0x820f27b4

 

 

The document is already read.

 

 

PS_ERR_DocNotRead

 

 

0x820f27b5

 

 

The document was not read.

 

 

Comments

 

The utility DSErrorLookUp.exe can provide additional error code data. This is a very useful application development tool and can be found in the installation folders. It is strongly recommended that developers utilize DSErrorLookUp.exe to debug their applications during the development process.

 

Example (C++)

 

// Using of PXCV_Err_FormatSeverity, PXCV_Err_FormatFacility, PXCV_Err_FormatErrorCode functions

charerr_message = NULL;

charbuf = NULL;

_PXCPagep = NULL;

    // Code below should always return an error and never work

HRESULT dummyError = PXCV_ReadDocumentW(NULLNULL0);

LONG sevLen = PXCV_Err_FormatSeverity(dummyErrorNULL0);

LONG facLen = PXCV_Err_FormatFacility(dummyErrorNULL0);

LONG descLen = PXCV_Err_FormatErrorCode(dummyErrorNULL0);

if ((sevLen > 0) && (facLen > 0) && (descLen > 0))

{

    // Total length of the formated text is the sum of the length for each description

    // plus some additional characters for formating

    LONG total = sevLen + facLen + descLen + 128;

    // allocate buffer for message

    err_message = new char[total];

    err_message[0] = '\0';

    // allocate temporary buffer

    buf = new char[total];

    // get error severity and append to message

    if (PXCV_Err_FormatSeverity(dummyErrorbuftotal) > 0)

        lstrcat(err_messagebuf);

    lstrcat(err_message, " [");

    // get error facility and append to message

    if (PXCV_Err_FormatFacility(dummyErrorbuftotal) > 0)

        lstrcat(err_messagebuf);

    lstrcat(err_message, "]: ");

    // and error code description and append to message

    if (PXCV_Err_FormatErrorCode(dummyErrorbuftotal) > 0)

        lstrcat(err_messagebuf);

    ::MessageBox(NULLerr_message"Test error"MB_OK);

    delete[] buf;

    delete[] err_message;

}