From afebbb876f0a21c827a5153ca907b8a75293ce79 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 1 Sep 2020 13:46:39 +0200 Subject: [PATCH] nix list-options: Ignore eval errors for now --- src/nix/options.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/nix/options.cc b/src/nix/options.cc index f0baa1e52..486063f01 100644 --- a/src/nix/options.cc +++ b/src/nix/options.cc @@ -55,11 +55,17 @@ struct CmdListOptions : InstallableCommand auto aValue = aFinal->value->attrs->get(option->name); assert(aValue); - std::ostringstream str; - JSONPlaceholder jsonOut(str); - PathSet context; - printValueAsJSON(*state, true, *aValue->value, jsonOut, context); - logger->stdout(" " ANSI_BOLD "Value:" ANSI_NORMAL " %s", str.str()); + try { + std::ostringstream str; + JSONPlaceholder jsonOut(str); + PathSet context; + printValueAsJSON(*state, true, *aValue->value, jsonOut, context); + logger->stdout(" " ANSI_BOLD "Value:" ANSI_NORMAL " %s", str.str()); + } catch (EvalError &) { + // FIXME: should ignore "no default" errors, print + // other errors. + logger->stdout(" " ANSI_BOLD "Value:" ANSI_NORMAL " " ANSI_ITALIC "none" ANSI_NORMAL); + } } } };