1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

Merge pull request #13248 from xokdvium/logger-exceptions

libmain: Catch logger exceptions in `handleExceptions`
This commit is contained in:
Jörg Thalheim 2025-05-23 15:26:13 +02:00 committed by GitHub
commit 81884c36a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -315,6 +315,7 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
ErrorInfo::programName = baseNameOf(programName);
std::string error = ANSI_RED "error:" ANSI_NORMAL " ";
try {
try {
try {
fun();
@ -342,6 +343,10 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
printError(error + e.what());
return 1;
}
} catch (...) {
/* In case logger also throws just give up. */
return 1;
}
return 0;
}