Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/libstore/sqlite.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion src/libutil/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/libutil/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/libutil/logging.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}