mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Prefer to throw specific errors
Signed-off-by: Pamplemousse <xav.maso@gmail.com>
This commit is contained in:
parent
decc14d4b7
commit
4a7a8b87cd
4 changed files with 6 additions and 6 deletions
|
@ -188,7 +188,7 @@ void MixProfile::updateProfile(const BuiltPaths & buildables)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.size() != 1)
|
if (result.size() != 1)
|
||||||
throw Error("'--profile' requires that the arguments produce a single store path, but there are %d", result.size());
|
throw UsageError("'--profile' requires that the arguments produce a single store path, but there are %d", result.size());
|
||||||
|
|
||||||
updateProfile(result[0]);
|
updateProfile(result[0]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ static Strings parseAttrPath(std::string_view s)
|
||||||
++i;
|
++i;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (i == s.end())
|
if (i == s.end())
|
||||||
throw Error("missing closing quote in selection path '%1%'", s);
|
throw ParseError("missing closing quote in selection path '%1%'", s);
|
||||||
if (*i == '"') break;
|
if (*i == '"') break;
|
||||||
cur.push_back(*i++);
|
cur.push_back(*i++);
|
||||||
}
|
}
|
||||||
|
@ -116,14 +116,14 @@ Pos findDerivationFilename(EvalState & state, Value & v, std::string what)
|
||||||
|
|
||||||
auto colon = pos.rfind(':');
|
auto colon = pos.rfind(':');
|
||||||
if (colon == std::string::npos)
|
if (colon == std::string::npos)
|
||||||
throw Error("cannot parse meta.position attribute '%s'", pos);
|
throw ParseError("cannot parse meta.position attribute '%s'", pos);
|
||||||
|
|
||||||
std::string filename(pos, 0, colon);
|
std::string filename(pos, 0, colon);
|
||||||
unsigned int lineno;
|
unsigned int lineno;
|
||||||
try {
|
try {
|
||||||
lineno = std::stoi(std::string(pos, colon + 1));
|
lineno = std::stoi(std::string(pos, colon + 1));
|
||||||
} catch (std::invalid_argument & e) {
|
} catch (std::invalid_argument & e) {
|
||||||
throw Error("cannot parse line number '%s'", pos);
|
throw ParseError("cannot parse line number '%s'", pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Symbol file = state.symbols.create(filename);
|
Symbol file = state.symbols.create(filename);
|
||||||
|
|
|
@ -908,7 +908,7 @@ void EvalState::evalFile(const Path & path_, Value & v, bool mustBeTrivial)
|
||||||
// computation.
|
// computation.
|
||||||
if (mustBeTrivial &&
|
if (mustBeTrivial &&
|
||||||
!(dynamic_cast<ExprAttrs *>(e)))
|
!(dynamic_cast<ExprAttrs *>(e)))
|
||||||
throw Error("file '%s' must be an attribute set", path);
|
throw EvalError("file '%s' must be an attribute set", path);
|
||||||
eval(e, v);
|
eval(e, v);
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
addErrorTrace(e, "while evaluating the file '%1%':", path2);
|
addErrorTrace(e, "while evaluating the file '%1%':", path2);
|
||||||
|
|
|
@ -32,7 +32,7 @@ ParsedURL parseURL(const std::string & url)
|
||||||
auto isFile = scheme.find("file") != std::string::npos;
|
auto isFile = scheme.find("file") != std::string::npos;
|
||||||
|
|
||||||
if (authority && *authority != "" && isFile)
|
if (authority && *authority != "" && isFile)
|
||||||
throw Error("file:// URL '%s' has unexpected authority '%s'",
|
throw BadURL("file:// URL '%s' has unexpected authority '%s'",
|
||||||
url, *authority);
|
url, *authority);
|
||||||
|
|
||||||
if (isFile && path.empty())
|
if (isFile && path.empty())
|
||||||
|
|
Loading…
Reference in a new issue