DynaPDF Manual - Page 18

Previous Page 17   Index   Next Page 19

Exception handling
Page 18 of 839
Exception handling
The DynaPDF library uses no native exception handling. It is not required to leave a function
block after an error occurred. All DynaPDF functions are leaved immediately when a fatal error
occurred without displaying further error messages.
The library always holds its internal state consistent, regardless what happens.
Exception handling in C, C++, C#, Delphi
Error messages and warnings are passed to a callback function (see SetOnErrorProc()) if set. If no
callback function is set, you must check the return value of important functions. Negative return
values indicate by default that an error occurred. Call GetErrorMessage() to get the last error
message in this case.
The Delphi interface uses native language exceptions in the following reasons:
When loading the dynapdf.dll (Cannot find dynapdf.dll)
When loading a DynaPDF function (Cannot find function: …)
When creating a new instance of the wrapper class TPDF (Out of memory).
Only these three exceptions can occur when using DynaPDF with Delphi. All other errors do not
raise an exception; the error callback function is called instead if any.
The error callback function is defined as follows (C/C++):
typedef SI32 PDF_CALL TErrorProc(
const void* Data,
// User defined pointer
SI32 ErrCode,
// Error code
const char* ErrMessage, // Error message
SI32 ErrType)
// Error type
#define PDF_CALL __stdcall // Windows only, otherwise empty
All callback functions contain a parameter named "Data" which holds a user defined pointer. Data
can be set with SetOnErrorProc(). If you don't need this pointer, set it to NULL. The pointer Data
is always passed unchanged to the callback function.
ErrCode is a positive error number starting at zero. ErrType is a bit mask to determine what kind
of error occurred. The following constants are defined:
#define E_WARNING
0x02000000
#define E_SYNTAX_ERROR 0x04000000
#define E_VALUE_ERROR
0x08000000
#define E_FONT_ERROR
0x10000000
#define E_FATAL_ERROR
0x20000000
#define E_FILE_ERROR
0x40000000
 

Previous topic: Data types used by different programming languages

Next topic: Exception handling in Visual Basic, Visual Basic .Net