SQLite Forum

Proposed addition to the sqlite3_result_XX API
Login
As it stands, you can use `sqlite3_result_error()` to return an error message from an extension, with the result code of `SQLITE_ERROR`.

Or, you can use `sqlite3_result_error_code()` to return a specific error code, but with the stock error message.

The first way is good if you want your extension functions to be useful for SQL developers, who are concerned that the error message makes sense for what they are trying to do.

The second way is good if you want your extension functions to be useful for application developers, since branching decisions are much easier based on error codes, and the error message is usually generated later in the application workflow anyway.

Unless I'm having one of my not-unheard-of brain farts, I can't find any way of returning a specific error code with a specific error message.

So my proposal is to add a function to the `vdbeapi.c` source along the lines of:

    SQLITE_API sqlite3_result_error_info(sqlite3_context *pCtx, const char *zError, int cbError, int errCode);

Ditto of course, for the UTF-16 version.