1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Add phase and error number to CLI error messages.

FossilOrigin-Name: 7f87a298688c37bbad8fd2e1cf0e8fbcc36f0c211dcfa3685298525648dbe21b
This commit is contained in:
larrybr
2021-10-26 16:57:09 +00:00
parent 629c2eaf46
commit f9a49b0cad
6 changed files with 28 additions and 26 deletions

View File

@@ -2606,17 +2606,16 @@ static int run_table_dump_query(
}
/*
** Allocate space and save off current error string.
** Allocate space and save off string indicating current error.
*/
static char *save_err_msg(
sqlite3 *db /* Database to query */
sqlite3 *db, /* Database to query */
const char *zWhen, /* Qualifier (format) wrapper */
int rc /* Error code returned from API */
){
int nErrMsg = 1+strlen30(sqlite3_errmsg(db));
char *zErrMsg = sqlite3_malloc64(nErrMsg);
if( zErrMsg ){
memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg);
}
return zErrMsg;
if( zWhen==0 )
zWhen = "%s (%d)";
return sqlite3_mprintf(zWhen, sqlite3_errmsg(db), rc);
}
#ifdef __linux__
@@ -3538,7 +3537,7 @@ static int shell_exec(
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
if( SQLITE_OK != rc ){
if( pzErrMsg ){
*pzErrMsg = save_err_msg(db);
*pzErrMsg = save_err_msg(db, "in prepare, %s (%d)", rc);
}
}else{
if( !pStmt ){
@@ -3652,7 +3651,7 @@ static int shell_exec(
zSql = zLeftover;
while( IsSpace(zSql[0]) ) zSql++;
}else if( pzErrMsg ){
*pzErrMsg = save_err_msg(db);
*pzErrMsg = save_err_msg(db, "stepping, %s (%d)", rc);
}
/* clear saved stmt handle */