Merge pull request #30087 from egggHang/ec_benchmark

test/erasure-code: add exception handling to k & m

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2019-09-09 20:24:20 +08:00 committed by GitHub
commit 8b88ab0f2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,10 +121,15 @@ int ErasureCodeBench::setup(int argc, char** argv) {
exhaustive_erasures = false;
if (vm.count("erased") > 0)
erased = vm["erased"].as<vector<int> >();
k = stoi(profile["k"]);
m = stoi(profile["m"]);
try {
k = stoi(profile["k"]);
m = stoi(profile["m"]);
} catch (const std::logic_error& e) {
cout << "Invalid k and/or m: k=" << profile["k"] << ", m=" << profile["m"]
<< " (" << e.what() << ")" << endl;
return -EINVAL;
}
if (k <= 0) {
cout << "parameter k is " << k << ". But k needs to be > 0." << endl;
return -EINVAL;