try-catch
This commit is contained in:
parent
f181c28edd
commit
8694318c71
1 changed files with 4 additions and 2 deletions
|
@ -42,8 +42,10 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
|
||||||
while (std::getline(cpuinfo, line)) {
|
while (std::getline(cpuinfo, line)) {
|
||||||
if (line.find("cpu cores") != std::string::npos) {
|
if (line.find("cpu cores") != std::string::npos) {
|
||||||
line.erase(0, line.find(": ") + 2);
|
line.erase(0, line.find(": ") + 2);
|
||||||
params.n_threads = std::stoul(line);
|
try {
|
||||||
break;
|
params.n_threads = std::stoul(line);
|
||||||
|
break;
|
||||||
|
} catch (std::invalid_argument& e) {} // Ignore if we could not parse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__APPLE__) && defined(__MACH__)
|
#elif defined(__APPLE__) && defined(__MACH__)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue