Skip to content

Commit

Permalink
More gracefully handle the case where trying to copy a measure from a…
Browse files Browse the repository at this point in the history
… directory that isn't a valid measure
  • Loading branch information
jmarrec committed May 3, 2023
1 parent d94ce99 commit 343867f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/cli/MeasureUpdateCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,13 @@ namespace cli {
->check(CLI::NonexistentPath);

copyMeasureSubCommand->callback([opt] {
// boost::optional<BCLMeasure> b_;
// try {
// b_ = BCLMeasure(opt->directoryPath);
// } catch (...) {
// throw std::runtime_error(fmt::format("Could not find a valid measure at '{}'\n", openstudio::toString(opt->directoryPath)));
// }
boost::optional<BCLMeasure> b_;
try {
b_ = BCLMeasure(opt->directoryPath);
} catch (...) {
fmt::print(stderr, "Could not find a valid measure at '{}'\n", openstudio::toString(opt->directoryPath));
std::exit(1);
}
// auto bClone_ = b_->clone(opt->newMeasureOpts.directoryPath);
auto b = BCLMeasure(opt->directoryPath);
auto bClone_ = b.clone(opt->newMeasureOpts.directoryPath);
Expand All @@ -288,7 +289,7 @@ namespace cli {
openstudio::toString(openstudio::filesystem::canonical(bClone_->directory())));
std::exit(0); // NOLINT(concurrency-mt-unsafe)
} else {
fmt::print("Something went wrong when cloning the measure");
fmt::print(stderr, "Something went wrong when cloning the measure");
std::exit(1); // NOLINT(concurrency-mt-unsafe)
}
});
Expand Down

0 comments on commit 343867f

Please sign in to comment.