Skip to content

Commit

Permalink
Capture std::regex_error
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Nov 5, 2018
1 parent f11124e commit 8e3eede
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/data/sparse_page_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ namespace {
// If cache info string contains drive letter (e.g. C:), exclude it before splitting
inline std::vector<std::string>
GetCacheShards(const std::string& cache_info) {
std::regex rgx("(^[A-Za-z]:)(.*)");
std::smatch matches;
if (std::regex_search(cache_info, matches, rgx)) {
std::vector<std::string> cache_shards
= xgboost::common::Split(matches[2].str(), ':');
cache_shards[0] = matches[1].str() + cache_shards[0];
return cache_shards;
} else {
return xgboost::common::Split(cache_info, ':');
try {
std::regex rgx("(^[A-Za-z]:)(.*)");
std::smatch matches;
if (std::regex_search(cache_info, matches, rgx)) {
std::vector<std::string> cache_shards
= xgboost::common::Split(matches[2].str(), ':');
cache_shards[0] = matches[1].str() + cache_shards[0];
return cache_shards;
} else {
return xgboost::common::Split(cache_info, ':');
}
} catch (std::regex_error& e) {
throw dmlc::Error(e.what());
}
}

Expand Down

0 comments on commit 8e3eede

Please sign in to comment.