UI: DbErrorManager: Debug some messages, not warn

This commit is contained in:
Nodir Temirkhodjaev 2024-02-05 11:26:51 +03:00
parent 8fda54d197
commit 499b861584
3 changed files with 14 additions and 1 deletions

View File

@ -677,6 +677,11 @@ bool SqliteDb::isIoError(int errCode)
return qint8(errCode) == SQLITE_IOERR;
}
bool SqliteDb::isDebugError(int errCode)
{
return qint8(errCode) == SQLITE_SCHEMA;
}
bool SqliteDb::setErrorLogCallback(SQLITEDB_ERRORLOG_FUNC errorLogFunc, void *context)
{
return sqlite3_config(SQLITE_CONFIG_LOG, errorLogFunc, context) == SQLITE_OK;

View File

@ -125,6 +125,7 @@ public:
SqliteStmt *stmt(const char *sql);
static bool isIoError(int errCode);
static bool isDebugError(int errCode);
static bool setErrorLogCallback(SQLITEDB_ERRORLOG_FUNC errorLogFunc, void *context = nullptr);

View File

@ -16,7 +16,14 @@ const QLoggingCategory LC("manager.dbError");
void sqliteLogHandler(void *context, int errCode, const char *message)
{
qCWarning(LC) << "Code:" << errCode << "Message:" << qUtf8Printable(message);
const auto messageLine =
QString("%1: %2").arg(QString::number(errCode), qUtf8Printable(message));
if (SqliteDb::isDebugError(errCode)) {
qCDebug(LC) << messageLine;
} else {
qCWarning(LC) << messageLine;
}
if (SqliteDb::isIoError(errCode)) {
auto manager = static_cast<DbErrorManager *>(context);