** Allocate space and save off string indicating current error. */
| 18008 | ** Allocate space and save off string indicating current error. |
| 18009 | */ |
| 18010 | static char *save_err_msg( |
| 18011 | sqlite3 *db, /* Database to query */ |
| 18012 | const char *zPhase, /* When the error occcurs */ |
| 18013 | int rc, /* Error code returned from API */ |
| 18014 | const char *zSql /* SQL string, or NULL */ |
| 18015 | ){ |
| 18016 | char *zErr; |
| 18017 | char *zContext; |
| 18018 | sqlite3_str *pStr = sqlite3_str_new(0); |
| 18019 | sqlite3_str_appendf(pStr, "%s, %s", zPhase, sqlite3_errmsg(db)); |
| 18020 | if( rc>1 ){ |
| 18021 | sqlite3_str_appendf(pStr, " (%d)", rc); |
| 18022 | } |
| 18023 | zContext = shell_error_context(zSql, db); |
| 18024 | if( zContext ){ |
| 18025 | sqlite3_str_appendall(pStr, zContext); |
| 18026 | sqlite3_free(zContext); |
| 18027 | } |
| 18028 | zErr = sqlite3_str_finish(pStr); |
| 18029 | shell_check_oom(zErr); |
| 18030 | return zErr; |
| 18031 | } |
| 18032 | |
| 18033 | #ifdef __linux__ |
| 18034 | /* |
no test coverage detected