From d8bc3bfb6d6618f8b6b0669cb5051f85192e5978 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Thu, 23 May 2024 02:52:54 +0200 Subject: 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 --- src/libcmd/repl.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/libcmd') diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 525c25560..a74ea8e5f 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -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. } } -- cgit v1.2.3