about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChuck <chuck@intelligence.org>2019-09-06 09:51:08 -0700
committerLinus Heckemann <git@sphalerite.org>2019-11-04 15:11:44 +0100
commit36c00c108076915b0074fefc8ae5bb8baba476fa (patch)
tree42c8a40904f80154f23e48c8f944f96fb584bf75
parent4af8dbf8964924dc3d2ec2bbfa159dae288b29fc (diff)
downloadnixlib-36c00c108076915b0074fefc8ae5bb8baba476fa.tar
nixlib-36c00c108076915b0074fefc8ae5bb8baba476fa.tar.gz
nixlib-36c00c108076915b0074fefc8ae5bb8baba476fa.tar.bz2
nixlib-36c00c108076915b0074fefc8ae5bb8baba476fa.tar.lz
nixlib-36c00c108076915b0074fefc8ae5bb8baba476fa.tar.xz
nixlib-36c00c108076915b0074fefc8ae5bb8baba476fa.tar.zst
nixlib-36c00c108076915b0074fefc8ae5bb8baba476fa.zip
Use format strings, not concatenation, in error messages
-rw-r--r--nixos/modules/installer/tools/nixos-option/nixos-option.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/nixos/modules/installer/tools/nixos-option/nixos-option.cc b/nixos/modules/installer/tools/nixos-option/nixos-option.cc
index fe44a347aefe..d72a2ae3f8db 100644
--- a/nixos/modules/installer/tools/nixos-option/nixos-option.cc
+++ b/nixos/modules/installer/tools/nixos-option/nixos-option.cc
@@ -479,25 +479,25 @@ Value findAlongOptionPath(Context * ctx, std::string const & path)
         auto const & attr = *i;
         v = evaluateValue(ctx, &v);
         if (attr.empty()) {
-            throw Error("empty attribute name in selection path '" + path + "'");
+            throw Error("empty attribute name in selection path '%s'", path);
         }
         if (isOption(ctx, v) && !last_attribute) {
             Value getSubOptions =
                 evaluateValue(ctx, findAlongAttrPath(*ctx->state, "type.getSubOptions", *ctx->autoArgs, v));
             if (getSubOptions.type != tLambda) {
-                throw Error("Option's type.getSubOptions isn't a function at '" + attr + "' in path '" + path + "'");
+                throw Error("Option's type.getSubOptions isn't a function at '%s' in path '%s'", attr, path);
             }
             Value emptyString{};
             nix::mkString(emptyString, "");
             ctx->state->callFunction(getSubOptions, emptyString, v, nix::Pos{});
             // Note that we've consumed attr, but didn't actually use it.
         } else if (v.type != tAttrs) {
-            throw Error("attribute '" + attr + "' in path '" + path +
-                        "' attempts to index a value that should be a set but is " + showType(v));
+            throw Error("attribute '%s' in path '%s' attempts to index a value that should be a set but is %s", attr,
+                        path, showType(v));
         } else {
             auto const & next = v.attrs->find(ctx->state->symbols.create(attr));
             if (next == v.attrs->end()) {
-                throw Error("attribute '" + attr + "' in path '" + path + "' not found");
+                throw Error("attribute '%s' in path '%s' not found", attr, path);
             }
             v = *next->value;
         }