SignDoc SDK (C)
5.0.0
|
Information about an exception. More...
#include <SignDocSDK-c.h>
Public Types | |
typedef void(* | SIGNDOC_ExceptionHandler) (struct SIGNDOC_Exception **aEx) |
Exception handler. More... | |
Public Member Functions | |
void | SIGNDOC_Exception_setHandler (SIGNDOC_ExceptionHandler aHandler) |
Sets an exception handler that is called when an exception occurs. More... | |
struct SIGNDOC_Exception * | SIGNDOC_Exception_new (unsigned aType, const char *aMessage) |
Create a new SIGNDOC_Exception object. More... | |
void | SIGNDOC_Exception_delete (struct SIGNDOC_Exception *aEx) |
Destroy a SIGNDOC_Exception object. More... | |
const char * | SIGNDOC_Exception_getText (const struct SIGNDOC_Exception *aEx) |
Get the message text of an SIGNDOC_Exception object. More... | |
unsigned | SIGNDOC_Exception_getType (const struct SIGNDOC_Exception *aEx) |
Get the type of the exception. More... | |
Information about an exception.
Functions which can throw exceptions take a
argument. You must pass a pointer to a variable of type
On entry, functions will check if the pointer is non-NULL. If it's NULL, abort() will be called. Otherwise, NULL will be stored to the object pointed to by that pointer.
When an exception occurs, an object of type SIGNDOC_Exception is created and a pointer to that exception is stored in the object pointed to by the aEx argument.
There are two ways to handle exceptions:
The most common exceptions are
Out of memory situations are always reported via an exception. Some but not all functions check for encoding errors and report any problems via return values.
typedef void( * SIGNDOC_ExceptionHandler) (struct SIGNDOC_Exception **aEx) |
Exception handler.
The exception handler passed to SIGNDOC_Exception_setHandler().
[in] | aEx | The aEx argument of the SignDoc SDK function which reports the exception. The pointer to the SIGNDOC_Exception object has already been stored to *aEx. If you call SIGNDOC_Exception_delete(*aEx), you must set *aEx to NULL. |
void SIGNDOC_Exception_delete | ( | struct SIGNDOC_Exception * | aEx | ) |
Destroy a SIGNDOC_Exception object.
If aEx points to the statically allocated object returned by SIGNDOC_Exception_new() in an out-of-memory situation, this function will do nothing.
[in] | aEx | A pointer to a SIGNDOC_Exception object, can be NULL. |
const char * SIGNDOC_Exception_getText | ( | const struct SIGNDOC_Exception * | aEx | ) |
Get the message text of an SIGNDOC_Exception object.
[in] | aEx | A pointer to a SIGNDOC_Exception object. |
unsigned SIGNDOC_Exception_getType | ( | const struct SIGNDOC_Exception * | aEx | ) |
Get the type of the exception.
[in] | aEx | A pointer to a SIGNDOC_Exception object. |
struct SIGNDOC_Exception * SIGNDOC_Exception_new | ( | unsigned | aType, |
const char * | aMessage | ||
) |
Create a new SIGNDOC_Exception object.
This function is needed only for throwing exceptions from callback functions such as SIGNDOC_UserInputStream_read().
[in] | aType | The type of the message: |
[in] | aMessage | A pointer to the message or NULL. The string will be copied. |
If creating the object or copying aMessage fails (due to lack of memory), this function will return a pointer to a special, statically SIGNDOC_Exception object which has type SIGNDOC_EXCEPTION_TYPE_BAD_ALLOC and a suitable message.
void SIGNDOC_Exception_setHandler | ( | SIGNDOC_ExceptionHandler | aHandler | ) |
Sets an exception handler that is called when an exception occurs.
Usage of this function is discouraged, check the object passed as aEx after each function call instead. The handler is global to the process.
[in] | aHandler | Exception handler function, NULL to disable. |