From 692c5a62a45223ea49dd3041decf3b1141124c88 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Wed, 6 Aug 2008 19:24:36 +0000 Subject: [PATCH] Use "abort" instead of "throw" when option values cannot be merged. Fix mergeListOption. Add error support in mergeEnableOption. svn path=/nixpkgs/trunk/; revision=12522 --- pkgs/lib/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index ac325350358b..7a89725c2121 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -364,13 +364,16 @@ rec { else if all __isFunction list then x: mergeDefaultOption (map (f: f x) list) else if all __isList list then concatLists list else if all __isAttrs list then mergeAttrs list - else throw "Default merge method does not work on '${name}'."; + else abort "${name}: Cannot merge values."; - mergeEnableOption = name: fold logicalOR false; + mergeEnableOption = name: list: + if all (x: true == x || false == x) list + then fold logicalOR false list + else abort "${name}: Expect a boolean value."; mergeListOption = name: list: - if all __isList list then list - else throw "${name}: Expect a list."; + if all __isList list then concatLists list + else abort "${name}: Expect a list."; # Merge sets of options and bindings. # noOption: function to call if no option is declared.