util.{hh,cc}: Move ignoreException to error.{hh,cc}

Change-Id: Iae6464217a55c313a983e5c651b26a4a1e446706
This commit is contained in:
Tom Hubrecht
2024-05-29 11:42:42 +02:00
parent 8b6d2d3915
commit 93ebb3e7df
5 changed files with 20 additions and 20 deletions
+1 -1
View File
@@ -1,9 +1,9 @@
#include "current-process.hh"
#include "error.hh"
#include "file-system.hh"
#include "logging.hh"
#include "namespaces.hh"
#include "signals.hh"
#include "util.hh"
#include "strings.hh"
#ifdef __APPLE__
+13
View File
@@ -417,4 +417,17 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s
return out;
}
void ignoreException(Verbosity lvl)
{
/* Make sure no exceptions leave this function.
printError() also throws when remote is closed. */
try {
try {
throw;
} catch (std::exception & e) {
printMsg(lvl, "error (ignored): %1%", e.what());
}
} catch (...) { }
}
}
+6
View File
@@ -202,4 +202,10 @@ public:
}
};
/**
* Exception handling in destructors: print an error message, then
* ignore the exception.
*/
void ignoreException(Verbosity lvl = lvlError);
}
-12
View File
@@ -70,18 +70,6 @@ namespace nix {
void ignoreException(Verbosity lvl)
{
/* Make sure no exceptions leave this function.
printError() also throws when remote is closed. */
try {
try {
throw;
} catch (std::exception & e) {
printMsg(lvl, "error (ignored): %1%", e.what());
}
} catch (...) { }
}
//////////////////////////////////////////////////////////////////////
-7
View File
@@ -39,13 +39,6 @@ struct Source;
extern const std::string nativeSystem;
/**
* Exception handling in destructors: print an error message, then
* ignore the exception.
*/
void ignoreException(Verbosity lvl = lvlError);
/**
* Get a value for the specified key from an associate container.