An Embeddable NoSQL Database Engine |
Tweet |
Follow @unqlite_db |
UnQLite C/C++ API Reference - Throw an error message.
int unqlite_context_throw_error(unqlite_context *pCtx,int iErr,const char *zErr);
int unqlite_context_throw_error_format(unqlite_context *pCtx,int iErr,const char *zFormat,...);
Throw an error message inside a foreign function.
Description
These
routines when invoked throw an error message to the installed Jx9 VM
Output Consumer Callback.
Note that the underlying Virtual Machine continues its execution normally when an error is thrown. If the caller want to stop program execution and thus to emulate the Jx9 die language construct inside a foreign function, simply return UNQLITE_ABORT instead of UNQLITE_OK;
Note that unqlite_context_throw_error() accepts a third argument which is the length of the string to output. If the nLen argument is less than zero, then zString is read up to the first zero terminator. If nLen is non-negative, then it is the maximum number of bytes read from zString.
unqlite_context_throw_error_format() is a work-alike of the "printf()" family of functions from the standard C library which is used to output a formatted string.
These routines accepts as their first argument a pointer to a unqlite_context which mean that they are designed to be invoked only from a foreign function.
These routines must be called from the same thread in which the application-defined function is running.
Parameters
pCtx |
Foreign function Call Context. |
iErr |
Severity level. This can be one of the following constants (Not a combination): UNQLITE_CTX_ERR Call context error such as: An unexpected number of arguments, invalid types and so forth. UNQLITE_CTX_WARNING Call context warning. UNQLITE_CTX_NOTICE Call context notice. |
Return value
UNQLITE_OK is returned on success. Any other return value indicates failure.
Example
Compile this C file for a smart introduction to these interfaces.
See also