From 52323b0b056f0588bdadd39566a7615f8aa5a4e2 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Sun, 11 Aug 2024 20:35:33 +0800 Subject: [PATCH] more user-friendly --- nixd/lib/Controller/AST.h | 2 +- nixd/lib/Controller/Definition.cpp | 5 ++--- nixd/tools/nixd/test/definition/builtin.md | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/nixd/lib/Controller/AST.h b/nixd/lib/Controller/AST.h index 6171cd450..3536f8197 100644 --- a/nixd/lib/Controller/AST.h +++ b/nixd/lib/Controller/AST.h @@ -41,7 +41,7 @@ struct VLAException : std::exception {}; struct NoLocationForBuiltinVariable : std::exception { [[nodiscard]] const char *what() const noexcept override { - return "builtin variable is not defined in nix source location"; + return "builtins are defined in the interpreter, not in the Nix files"; } }; diff --git a/nixd/lib/Controller/Definition.cpp b/nixd/lib/Controller/Definition.cpp index d64976545..95bbebea4 100644 --- a/nixd/lib/Controller/Definition.cpp +++ b/nixd/lib/Controller/Definition.cpp @@ -312,9 +312,8 @@ defineVar(const ExprVar &Var, const VariableLookupAnalysis &VLA, return StaticLocs; } } catch (std::exception &E) { - // Pop a window, notify the user we cannot find static definition. - // Likely this will be triggerred by clicking "builtins" - return error(E.what()); + elog("definition/static: {0}", E.what()); + return Locations{}; } return error("unreachable code! Please submit an issue"); } diff --git a/nixd/tools/nixd/test/definition/builtin.md b/nixd/tools/nixd/test/definition/builtin.md index 9e31451cb..cccd8ee04 100644 --- a/nixd/tools/nixd/test/definition/builtin.md +++ b/nixd/tools/nixd/test/definition/builtin.md @@ -56,9 +56,9 @@ ``` ``` -CHECK: "message": "builtin variable is not defined in nix source location" -CHECK-NEXT: }, -CHECK-NEXT: "id": 2, + CHECK: "id": 2, +CHECK-NEXT: "jsonrpc": "2.0", +CHECK-NEXT: "result": null ```