throw_ -> reportError

This function might or might not throw depending on the value of
`keepGoing`, so naming it `throw_` was a bit confusing
This commit is contained in:
regnat 2021-06-02 11:24:31 +02:00
parent d12b12a15b
commit 7d651f5c3f

View file

@ -273,7 +273,7 @@ struct CmdFlakeCheck : FlakeCommand
auto flake = lockFlake(); auto flake = lockFlake();
bool hasErrors = false; bool hasErrors = false;
auto throw_ = [&](const Error & e) { auto reportError = [&](const Error & e) {
try { try {
throw e; throw e;
} catch (Error & e) { } catch (Error & e) {
@ -291,7 +291,7 @@ struct CmdFlakeCheck : FlakeCommand
auto checkSystemName = [&](const std::string & system, const Pos & pos) { auto checkSystemName = [&](const std::string & system, const Pos & pos) {
// FIXME: what's the format of "system"? // FIXME: what's the format of "system"?
if (system.find('-') == std::string::npos) if (system.find('-') == std::string::npos)
throw_(Error("'%s' is not a valid system type, at %s", system, pos)); reportError(Error("'%s' is not a valid system type, at %s", system, pos));
}; };
auto checkDerivation = [&](const std::string & attrPath, Value & v, const Pos & pos) -> std::optional<StorePath> { auto checkDerivation = [&](const std::string & attrPath, Value & v, const Pos & pos) -> std::optional<StorePath> {
@ -303,7 +303,7 @@ struct CmdFlakeCheck : FlakeCommand
return std::make_optional(store->parseStorePath(drvInfo->queryDrvPath())); return std::make_optional(store->parseStorePath(drvInfo->queryDrvPath()));
} catch (Error & e) { } catch (Error & e) {
e.addTrace(pos, hintfmt("while checking the derivation '%s'", attrPath)); e.addTrace(pos, hintfmt("while checking the derivation '%s'", attrPath));
throw_(e); reportError(e);
} }
return std::nullopt; return std::nullopt;
}; };
@ -322,7 +322,7 @@ struct CmdFlakeCheck : FlakeCommand
#endif #endif
} catch (Error & e) { } catch (Error & e) {
e.addTrace(pos, hintfmt("while checking the app definition '%s'", attrPath)); e.addTrace(pos, hintfmt("while checking the app definition '%s'", attrPath));
throw_(e); reportError(e);
} }
}; };
@ -338,7 +338,7 @@ struct CmdFlakeCheck : FlakeCommand
// evaluate the overlay. // evaluate the overlay.
} catch (Error & e) { } catch (Error & e) {
e.addTrace(pos, hintfmt("while checking the overlay '%s'", attrPath)); e.addTrace(pos, hintfmt("while checking the overlay '%s'", attrPath));
throw_(e); reportError(e);
} }
}; };
@ -362,7 +362,7 @@ struct CmdFlakeCheck : FlakeCommand
// check the module. // check the module.
} catch (Error & e) { } catch (Error & e) {
e.addTrace(pos, hintfmt("while checking the NixOS module '%s'", attrPath)); e.addTrace(pos, hintfmt("while checking the NixOS module '%s'", attrPath));
throw_(e); reportError(e);
} }
}; };
@ -384,7 +384,7 @@ struct CmdFlakeCheck : FlakeCommand
} catch (Error & e) { } catch (Error & e) {
e.addTrace(pos, hintfmt("while checking the Hydra jobset '%s'", attrPath)); e.addTrace(pos, hintfmt("while checking the Hydra jobset '%s'", attrPath));
throw_(e); reportError(e);
} }
}; };
@ -399,7 +399,7 @@ struct CmdFlakeCheck : FlakeCommand
throw Error("attribute 'config.system.build.toplevel' is not a derivation"); throw Error("attribute 'config.system.build.toplevel' is not a derivation");
} catch (Error & e) { } catch (Error & e) {
e.addTrace(pos, hintfmt("while checking the NixOS configuration '%s'", attrPath)); e.addTrace(pos, hintfmt("while checking the NixOS configuration '%s'", attrPath));
throw_(e); reportError(e);
} }
}; };
@ -433,7 +433,7 @@ struct CmdFlakeCheck : FlakeCommand
} }
} catch (Error & e) { } catch (Error & e) {
e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath)); e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath));
throw_(e); reportError(e);
} }
}; };
@ -448,7 +448,7 @@ struct CmdFlakeCheck : FlakeCommand
throw Error("bundler must take formal arguments 'program' and 'system'"); throw Error("bundler must take formal arguments 'program' and 'system'");
} catch (Error & e) { } catch (Error & e) {
e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath)); e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath));
throw_(e); reportError(e);
} }
}; };
@ -589,7 +589,7 @@ struct CmdFlakeCheck : FlakeCommand
} catch (Error & e) { } catch (Error & e) {
e.addTrace(pos, hintfmt("while checking flake output '%s'", name)); e.addTrace(pos, hintfmt("while checking flake output '%s'", name));
throw_(e); reportError(e);
} }
}); });
} }