Skip to content

Commit

Permalink
add error for non-existant main file in batch group
Browse files Browse the repository at this point in the history
  • Loading branch information
PredatorCZ committed Mar 23, 2024
1 parent b817741 commit f7fc343
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/app/batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ void WorkerThread::operator()() {
try {
item();
} catch (const std::exception &e) {
printerror(e.what());
PrintError(e.what());
} catch (...) {
printerror("Uncaught exception");
PrintError("Uncaught exception");
}
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ void SimpleManager::Push(SimpleManager::FuncType item) {
try {
item();
} catch (const std::exception &e) {
printerror(e.what());
PrintError(e.what());
}
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ void Batch::AddBatch(nlohmann::json &batch, const std::string &batchPath) {
for (std::string item : group) {
if (batchControlFilter.IsFiltered(item)) {
if (!controlPath.empty()) {
printerror("Dupicate main file for batch: " << item);
PrintError("Dupicate main file in batch group: ", item);
continue;
}

Expand All @@ -213,6 +213,11 @@ void Batch::AddBatch(nlohmann::json &batch, const std::string &batchPath) {
supplementals.emplace_back(batchPath + item);
}

if (controlPath.empty()) {
PrintError("Main file not provided for batch group");
continue;
}

manager.Push(
[&, iCtx{MakeIOContext(controlPath, std::move(supplementals))}] {
forEachFile(iCtx.get());
Expand Down Expand Up @@ -357,7 +362,7 @@ void Batch::AddFile(std::string path) {
if (type == FileType_e::File) {
if (!ctx->info->batchControlFilters.empty()) {
if (!path.ends_with("batch.json")) {
printerror("Expected json bach, got: " << path);
PrintError("Expected json bach, got: ", path);
break;
}

Expand All @@ -378,7 +383,7 @@ void Batch::AddFile(std::string path) {
}
break;
}
printerror("Invalid path: " << path);
PrintError("Invalid path: ", path);
break;
}
}
Expand Down

0 comments on commit f7fc343

Please sign in to comment.