forked from lix-project/lix
feat: add try-catch to some usages of readLine
This commit is contained in:
parent
ac6974777e
commit
e6e97811de
|
@ -558,7 +558,14 @@ std::optional<char> ProgressBar::ask(std::string_view msg)
|
|||
auto state(state_.lock());
|
||||
if (state->paused > 0 || !isatty(STDIN_FILENO)) return {};
|
||||
std::cerr << fmt("\r\e[K%s ", msg);
|
||||
auto s = trim(readLine(STDIN_FILENO));
|
||||
auto s = [&]() {
|
||||
try {
|
||||
return trim(readLine(STDIN_FILENO));
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "while trying to read from STDIN to ask something");
|
||||
throw;
|
||||
}
|
||||
}();
|
||||
if (s.size() != 1) return {};
|
||||
draw(*state, {});
|
||||
return s[0];
|
||||
|
|
|
@ -930,7 +930,14 @@ Pid LinuxLocalDerivationGoal::startChild(std::function<void()> openSlave)
|
|||
userNamespaceSync.writeSide.reset();
|
||||
});
|
||||
|
||||
auto ss = tokenizeString<std::vector<std::string>>(readLine(sendPid.readSide.get()));
|
||||
auto ss = [&]() {
|
||||
try {
|
||||
return tokenizeString<std::vector<std::string>>(readLine(sendPid.readSide.get()));
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "while... how am I supposed to know?");
|
||||
throw;
|
||||
}
|
||||
}();
|
||||
assert(ss.size() == 1);
|
||||
Pid pid = Pid{string2Int<pid_t>(ss[0]).value()};
|
||||
|
||||
|
|
Loading…
Reference in a new issue