mirror of
https://github.com/NixOS/nix
synced 2025-06-30 19:57:59 +02:00
Decode virtual paths in user-thrown errors
E.g. instead of error: Package ‘steam’ in /__virtual__/4/pkgs/games/steam/steam.nix:43 has an unfree license (‘unfreeRedistributable’), refusing to evaluate. you now get error: Package ‘steam’ in «github:nixos/nixpkgs/b82ccafb54163ab9024e893e578d840577785fea»/pkgs/games/steam/steam.nix:43 has an unfree license (‘unfreeRedistributable’), refusing to evaluate.
This commit is contained in:
parent
b293b33322
commit
48a5879b63
4 changed files with 39 additions and 4 deletions
|
@ -63,4 +63,34 @@ SourcePath EvalState::decodePath(std::string_view s, PosIdx pos)
|
|||
return {rootFS, CanonPath(s)};
|
||||
}
|
||||
|
||||
std::string EvalState::decodePaths(std::string_view s)
|
||||
{
|
||||
std::string res;
|
||||
|
||||
size_t pos = 0;
|
||||
|
||||
while (true) {
|
||||
auto m = s.find(marker, pos);
|
||||
if (m == s.npos) {
|
||||
res.append(s.substr(pos));
|
||||
return res;
|
||||
}
|
||||
|
||||
res.append(s.substr(pos, m - pos));
|
||||
|
||||
auto end = s.find_first_of(" \n\r\t'\"’:", m);
|
||||
if (end == s.npos) end = s.size();
|
||||
|
||||
try {
|
||||
auto path = decodePath(s.substr(m, end - m), noPos);
|
||||
res.append(path.to_string());
|
||||
} catch (...) {
|
||||
throw;
|
||||
res.append(s.substr(pos, end - m));
|
||||
}
|
||||
|
||||
pos = end;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue