diff --git a/apdUnitCreator.cpp b/apdUnitCreator.cpp index ed0b0681fe9293d496418916bfe110970ffa0e27..be132ef80201d132d1d71ca068f3aa432ef60124 100644 --- a/apdUnitCreator.cpp +++ b/apdUnitCreator.cpp @@ -47,20 +47,24 @@ int main(int argc, char* argv[]) { } if (debug) cout << "Connection successful!" << endl; + int nFailed = 0; for (auto newUnit = newUnits.begin(); newUnit < newUnits.end(); newUnit++) { try { proddb->createApdCapsule(newUnit->redSerial, newUnit->blueSerial); std::string capsuleSerial = newUnit->blueSerial + "/" + newUnit->redSerial; proddb->createApdUnit(capsuleSerial, newUnit->crystalSerial, newUnit->barCode); } - catch (exception e) { + catch (std::exception e) { + nFailed++; std::cerr << "An error occurred on APD paid with red APD " << newUnit->redSerial << " and blue APD " << newUnit->blueSerial << "!" << std::endl; - std::cerr << e.what(); + std::cerr << e.what() << std::endl << std::endl; continue; } } - cout << "Created " << newUnits.size() << " APD Capsules and assigned them to Units."; + cout << "Created " << newUnits.size() << " APD Capsules and assigned them to Units." << std::endl; + if (nFailed > 0) + cerr << "Data entry failed for " << nFailed << " entries!" << std::endl; return (-newUnits.empty()); }