repl: do not crash when tab-completing import errors

File not found while importing causes a SysError, not an EvalError,
which is not currently caught by the tab-completion handler. Ignoring
all SysErrors might seem "dangerous" but this is the tab-completion
handler, any exception being bubbled up from there causes unexpected
behavior (causes the whole repl to exit).

Fixes #340.

Change-Id: I643048a47935e77f582decc539d9e51bdb96c890
This commit is contained in:
Pierre Bourdon 2024-05-23 02:52:54 +02:00
parent 06c1375e52
commit d8bc3bfb6d
Signed by untrusted user: delroth
GPG key ID: 6FB80DCD84DA0F1C

View file

@ -375,6 +375,9 @@ StringSet NixRepl::completePrefix(const std::string & prefix)
// Quietly ignore evaluation errors.
} catch (BadURL & e) {
// Quietly ignore BadURL flake-related errors.
} catch (SysError & e) {
// Quietly ignore system errors which can for example be raised by
// a non-existent file being `import`-ed.
}
}