mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
edit: Catch stoi exceptions from line number parsing
This commit is contained in:
parent
f9bcbddef2
commit
626a94d70e
1 changed files with 6 additions and 1 deletions
|
@ -52,7 +52,12 @@ struct CmdEdit : InstallableCommand
|
|||
throw Error("cannot parse meta.position attribute '%s'", pos);
|
||||
|
||||
std::string filename(pos, 0, colon);
|
||||
int lineno = std::stoi(std::string(pos, colon + 1));
|
||||
int lineno;
|
||||
try {
|
||||
lineno = std::stoi(std::string(pos, colon + 1));
|
||||
} catch (std::invalid_argument e) {
|
||||
throw Error("cannot parse line number '%s'", pos);
|
||||
}
|
||||
|
||||
auto editor = getEnv("EDITOR", "cat");
|
||||
|
||||
|
|
Loading…
Reference in a new issue