forked from lix-project/lix
In SQLite errors, include the database path
This is necessary because we have multiple SQLite databases (e.g. the binary cache cache).
This commit is contained in:
parent
7251d048fa
commit
80027144ae
|
@ -8,13 +8,17 @@ namespace nix {
|
||||||
[[noreturn]] void throwSQLiteError(sqlite3 * db, const format & f)
|
[[noreturn]] void throwSQLiteError(sqlite3 * db, const format & f)
|
||||||
{
|
{
|
||||||
int err = sqlite3_errcode(db);
|
int err = sqlite3_errcode(db);
|
||||||
|
|
||||||
|
auto path = sqlite3_db_filename(db, nullptr);
|
||||||
|
if (!path) path = "(in-memory)";
|
||||||
|
|
||||||
if (err == SQLITE_BUSY || err == SQLITE_PROTOCOL) {
|
if (err == SQLITE_BUSY || err == SQLITE_PROTOCOL) {
|
||||||
if (err == SQLITE_PROTOCOL)
|
if (err == SQLITE_PROTOCOL)
|
||||||
printError("warning: SQLite database is busy (SQLITE_PROTOCOL)");
|
printError("warning: SQLite database ‘%s’ is busy (SQLITE_PROTOCOL)", path);
|
||||||
else {
|
else {
|
||||||
static bool warned = false;
|
static bool warned = false;
|
||||||
if (!warned) {
|
if (!warned) {
|
||||||
printError("warning: SQLite database is busy");
|
printError("warning: SQLite database ‘%s’ is busy", path);
|
||||||
warned = true;
|
warned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +33,10 @@ namespace nix {
|
||||||
#else
|
#else
|
||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
throw SQLiteBusy(format("%1%: %2%") % f.str() % sqlite3_errmsg(db));
|
throw SQLiteBusy("%s: %s (in ‘%s’)", f.str(), sqlite3_errstr(err), path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw SQLiteError(format("%1%: %2%") % f.str() % sqlite3_errmsg(db));
|
throw SQLiteError("%s: %s (in ‘%s’)", f.str(), sqlite3_errstr(err), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLite::SQLite(const Path & path)
|
SQLite::SQLite(const Path & path)
|
||||||
|
|
Loading…
Reference in a new issue