1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-18 10:30:23 -04:00

Remove "error:" prefix to SQLite warning message

Avoid the confusing error message "warning: error: ..." when SQLite is
busy.  Instead, just print "warning: ..." as the message.

Fixes #6656
This commit is contained in:
Jean-François Roche 2024-03-25 12:40:15 +01:00
parent 641b0bd746
commit 920b87f94b
4 changed files with 19 additions and 2 deletions

View file

@ -158,7 +158,12 @@ protected:
};
MakeError(SQLiteBusy, SQLiteError);
struct SQLiteBusy : SQLiteError
{
SQLiteBusy(const char *path, const char *errMsg, int errNo, int extendedErrNo, int offset, HintFmt && hf)
: SQLiteError(path, errMsg, errNo, extendedErrNo, offset, std::move(hf))
{ err.level = lvlWarn; }
};
void handleSQLiteBusy(const SQLiteBusy & e, time_t & nextWarning);

View file

@ -25,8 +25,12 @@ void throwExceptionSelfCheck(){
// This stringifies the error and caches it for use by what(), or similarly by msg().
const std::string & BaseError::calcWhat() const
{
if (what_.has_value())
if (what_.has_value()) {
if (err.level == Verbosity::lvlWarn) {
removeErrorPrefix(*what_);
}
return *what_;
}
else {
std::ostringstream oss;
showErrorInfo(oss, err, loggerSettings.showTrace);

View file

@ -324,6 +324,12 @@ bool handleJSONLogMessage(const std::string & msg,
return handleJSONLogMessage(*json, act, activities, trusted);
}
void removeErrorPrefix(std::string & msg)
{
if (hasPrefix(msg, "error: "))
msg.erase(0, 7);
}
Activity::~Activity()
{
try {

View file

@ -257,4 +257,6 @@ inline void warn(const std::string & fs, const Args & ... args)
void writeToStderr(std::string_view s);
void removeErrorPrefix(std::string & msg);
}