summary refs log tree commit diff
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2022-03-07 17:28:20 +0100
committerehmry <ehmry@posteo.net>2022-03-09 14:53:04 +0000
commit9a5b1d3ca2b0765b0ae280aa94bbd8fb143cfec0 (patch)
tree689c5127e9a625b952b1eb8b236b8d22f100a8d5
parent878480eec4b0c471f6ba245c58ea787bde032358 (diff)
downloadnixpkgs-9a5b1d3ca2b0765b0ae280aa94bbd8fb143cfec0.tar
nixpkgs-9a5b1d3ca2b0765b0ae280aa94bbd8fb143cfec0.tar.gz
nixpkgs-9a5b1d3ca2b0765b0ae280aa94bbd8fb143cfec0.tar.bz2
nixpkgs-9a5b1d3ca2b0765b0ae280aa94bbd8fb143cfec0.tar.lz
nixpkgs-9a5b1d3ca2b0765b0ae280aa94bbd8fb143cfec0.tar.xz
nixpkgs-9a5b1d3ca2b0765b0ae280aa94bbd8fb143cfec0.tar.zst
nixpkgs-9a5b1d3ca2b0765b0ae280aa94bbd8fb143cfec0.zip
makeDesktopItem: improve error messages
-rw-r--r--pkgs/build-support/make-desktopitem/default.nix24
1 files changed, 12 insertions, 12 deletions
diff --git a/pkgs/build-support/make-desktopitem/default.nix b/pkgs/build-support/make-desktopitem/default.nix
index 31964953247..d831fe24d33 100644
--- a/pkgs/build-support/make-desktopitem/default.nix
+++ b/pkgs/build-support/make-desktopitem/default.nix
@@ -36,7 +36,7 @@
 let
   # FIXME: workaround until https://github.com/NixOS/nixpkgs/pull/162246 lands
   cleanName = if lib.hasInfix " " name
-                then throw "Name must not contain spaces!"
+                then throw "makeDesktopItem: name must not contain spaces!"
                 else name;
 
   # There are multiple places in the FDO spec that make "boolean" values actually tristate,
@@ -45,13 +45,13 @@ let
   boolOrNullToString = value:
     if value == null then null
     else if builtins.isBool value then lib.boolToString value
-    else throw "Value must be a boolean or null!";
+    else throw "makeDesktopItem: value must be a boolean or null!";
 
   # Multiple values are represented as one string, joined by semicolons.
   # Technically, it's possible to escape semicolons in values with \;, but this is currently not implemented.
-  renderList = value:
-    if !builtins.isList value then throw "Value must be a list!"
-    else if builtins.any (item: lib.hasInfix ";" item) value then throw "Values in list must not contain semicolons!"
+  renderList = key: value:
+    if !builtins.isList value then throw "makeDesktopItem: value for ${key} must be a list!"
+    else if builtins.any (item: lib.hasInfix ";" item) value then throw "makeDesktopItem: values in ${key} list must not contain semicolons!"
     else if value == [] then null
     else builtins.concatStringsSep ";" value;
 
@@ -65,18 +65,18 @@ let
     "NoDisplay" = boolOrNullToString noDisplay;
     "Comment" = comment;
     "Icon" = icon;
-    "OnlyShowIn" = renderList onlyShowIn;
-    "NotShowIn" = renderList notShowIn;
+    "OnlyShowIn" = renderList "onlyShowIn" onlyShowIn;
+    "NotShowIn" = renderList "notShowIn" notShowIn;
     "DBusActivatable" = boolOrNullToString dbusActivatable;
     "TryExec" = tryExec;
     "Exec" = exec;
     "Path" = path;
     "Terminal" = boolOrNullToString terminal;
-    "Actions" = renderList (builtins.attrNames actions);
-    "MimeType" = renderList mimeTypes;
-    "Categories" = renderList categories;
-    "Implements" = renderList implements;
-    "Keywords" = renderList keywords;
+    "Actions" = renderList "actions" (builtins.attrNames actions);
+    "MimeType" = renderList "mimeTypes" mimeTypes;
+    "Categories" = renderList "categories" categories;
+    "Implements" = renderList "implements" implements;
+    "Keywords" = renderList "keywords" keywords;
     "StartupNotify" = boolOrNullToString startupNotify;
     "StartupWMClass" = startupWMClass;
     "URL" = url;