mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
Revert some changes: try/catch block, and comments
This commit is contained in:
parent
e5f9c7e622
commit
93e27e5a28
1 changed files with 10 additions and 5 deletions
|
@ -31,9 +31,14 @@ CConfigManager::CConfigManager() {
|
||||||
if (ifs.is_open()) {
|
if (ifs.is_open()) {
|
||||||
while (std::getline(ifs, line)) {
|
while (std::getline(ifs, line)) {
|
||||||
// Read line by line
|
// Read line by line
|
||||||
// The cause of the error is
|
try {
|
||||||
// written in this->parseError
|
parseLine(line);
|
||||||
parseLine(line);
|
} catch (...) {
|
||||||
|
Debug::log(ERR, "Error reading line from config. Line:");
|
||||||
|
Debug::log(NONE, "%s", line.c_str());
|
||||||
|
|
||||||
|
parseError += "Config error at line " + std::to_string(linenum) + ": Line parsing error.";
|
||||||
|
}
|
||||||
|
|
||||||
if (!parseError.empty()) {
|
if (!parseError.empty()) {
|
||||||
// If an error there is, user may want the precise line where it occured
|
// If an error there is, user may want the precise line where it occured
|
||||||
|
@ -67,12 +72,12 @@ std::string CConfigManager::removeBeginEndSpacesTabs(std::string str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::parseLine(std::string& line) {
|
void CConfigManager::parseLine(std::string& line) {
|
||||||
// First check if it's not a comment
|
// first check if its not a comment
|
||||||
const auto COMMENTSTART = line.find_first_of('#');
|
const auto COMMENTSTART = line.find_first_of('#');
|
||||||
if (COMMENTSTART == 0)
|
if (COMMENTSTART == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Remove comment from string
|
// now, cut the comment off
|
||||||
if (COMMENTSTART != std::string::npos)
|
if (COMMENTSTART != std::string::npos)
|
||||||
line = line.substr(0, COMMENTSTART);
|
line = line.substr(0, COMMENTSTART);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue