diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-01-27 03:17:47 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-05 17:17:46 +0100 |
commit | 0079e977109bfa1a4226bc399fb7888d28292b3c (patch) | |
tree | 3be2ce7eb3251713f9c49cb63ea2d940e654a71a | |
parent | 384e1f24d3fbd816a272e86911389c145e0cac7f (diff) | |
download | usdx-0079e977109bfa1a4226bc399fb7888d28292b3c.tar.gz usdx-0079e977109bfa1a4226bc399fb7888d28292b3c.tar.xz usdx-0079e977109bfa1a4226bc399fb7888d28292b3c.zip |
added try ... catch for each line and warn if error at line
-rw-r--r-- | src/base/songloading/songloading_strategy_txt.cpp | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/src/base/songloading/songloading_strategy_txt.cpp b/src/base/songloading/songloading_strategy_txt.cpp index 26809d2a..0f9e3fff 100644 --- a/src/base/songloading/songloading_strategy_txt.cpp +++ b/src/base/songloading/songloading_strategy_txt.cpp @@ -138,38 +138,44 @@ namespace usdx bool SongloadingStrategyTxt::parse_line(Song* song, File& file, const int line_number) { - std::string line; - std::getline(file.stream(), line); + try { + std::string line; + std::getline(file.stream(), line); - char type; - std::istringstream linestream(line); - linestream >> std::skipws >> type; + char type; + std::istringstream linestream(line); + linestream >> std::skipws >> type; - if (type == '#') { - // ignore, header already read - } - else if (type == 'E') { - // song end - if (file.stream().eof()) { - LOG4CXX_WARN(log, "End marker found in line " << line_number << - " before end of file: '" << song->get_filename() << "'."); + if (type == '#') { + // ignore, header already read } + else if (type == 'E') { + // song end + if (file.stream().eof()) { + LOG4CXX_WARN(log, "End marker found in line " << line_number << + " before end of file: '" << song->get_filename() << "'."); + } - return false; - } - else if (type == '-') { - parse_newline(song, linestream, line_number); - } - else if (type == 'B') { - parse_bpm(song, linestream, line_number); - } - else if (type == ':' || type == 'F' || type == '*') { - parse_note(song, type, linestream, line_number); + return false; + } + else if (type == '-') { + parse_newline(song, linestream, line_number); + } + else if (type == 'B') { + parse_bpm(song, linestream, line_number); + } + else if (type == ':' || type == 'F' || type == '*') { + parse_note(song, type, linestream, line_number); + } + else { + LOG4CXX_WARN(log, "Unknown line in song: '" << line << + "' in file: " << song->get_filename() << + " at line " << line_number); + } } - else { - LOG4CXX_WARN(log, "Unknown line in song: '" << line << - "' in file: " << song->get_filename() << - " at line " << line_number); + catch (std::exception &e) { + LOG4CXX_WARN(log, "Error in song file at line " << + line_number << ": " << e.what()); } return true; |