Better error messages when parsing version information fails

This commit is contained in:
Sebastian Messmer 2016-03-31 21:18:39 +08:00
parent 4069358b31
commit f5305aa95d

View File

@ -76,12 +76,12 @@ namespace gitversion {
string commitsSinceTag;
getline(stream, commitsSinceTag, '.');
if (!stream.good()) {
throw std::logic_error("Invalid version information: Missing delimiter after commitsSinceTag.");
throw std::logic_error("Invalid version information: Missing delimiter after commitsSinceTag (versionInfo: "+versionInfo+").");
}
string gitCommitId;
getline(stream, gitCommitId, '.');
if (gitCommitId[0] != 'g') {
throw std::logic_error("Invalid version information: Git commit id component doesn't start with 'g'.");
throw std::logic_error("Invalid version information: Git commit id component doesn't start with 'g' (versionInfo: "+versionInfo+").");
}
return std::make_tuple(gitCommitId.substr(1), std::stoul(commitsSinceTag));
}