1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-04 03:01:47 +02:00

Split ignoreException for destructors or interrupt-safe

This commit is contained in:
Robert Hensing 2024-09-30 11:49:53 +02:00
parent a1415471b8
commit 3df619339c
27 changed files with 164 additions and 125 deletions

View file

@ -1,6 +1,7 @@
#include "util.hh"
#include "fmt.hh"
#include "file-path.hh"
#include "signals.hh"
#include <array>
#include <cctype>
@ -182,7 +183,7 @@ std::string shellEscape(const std::string_view s)
}
void ignoreException(Verbosity lvl)
void ignoreExceptionInDestructor(Verbosity lvl)
{
/* Make sure no exceptions leave this function.
printError() also throws when remote is closed. */
@ -195,6 +196,17 @@ void ignoreException(Verbosity lvl)
} catch (...) { }
}
void ignoreExceptionExceptInterrupt(Verbosity lvl)
{
try {
throw;
} catch (const Interrupted & e) {
throw;
} catch (std::exception & e) {
printMsg(lvl, "error (ignored): %1%", e.what());
}
}
constexpr char base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";