diff --git a/ffmpeglauncher.cpp b/ffmpeglauncher.cpp index f6e4217..a9140b3 100644 --- a/ffmpeglauncher.cpp +++ b/ffmpeglauncher.cpp @@ -92,21 +92,20 @@ void FfmpegLauncher::nextSong() infoIni.parse(infoFile); // read length scope, only possible if track number known because the track number is used for mapping if(m_watcher.trackNumber()) { - try { - const auto &lengthScope = infoIni.data().at("length"); - for(const auto &entry : lengthScope) { - try { - if(stringToNumber(entry.first) == m_watcher.trackNumber()) { - // length entry for this track - length = QString::fromLocal8Bit(entry.second.data()); - break; + for(auto &scope : infoIni.data()) { + if(scope.first == "length") { + for(const auto &entry : scope.second) { + try { + if(stringToNumber(entry.first) == m_watcher.trackNumber()) { + // length entry for this track + length = QString::fromLocal8Bit(entry.second.data()); + break; + } + } catch( const ConversionException &) { + cerr << "Warning: Ignoring non-numeric key \"" << entry.first << "\" in info.ini." << endl; } - } catch( const ConversionException &) { - cerr << "Warning: Ignoring non-numeric key \"" << entry.first << "\" in info.ini." << endl; } } - } catch(const out_of_range &) { - // no length for the current track specified } } } catch(const ios_base::failure &) { diff --git a/main.cpp b/main.cpp index afe638c..3fb3c9d 100644 --- a/main.cpp +++ b/main.cpp @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) parser.parseArgs(argc, argv); } catch (const Failure &e) { cerr << "Unable to parse arguments: " << e.what() << endl; - return 2; + return 1; } try { if(recordArg.isPresent()) { @@ -80,9 +80,12 @@ int main(int argc, char *argv[]) } // enter app loop return app.exec(); + } else { + cerr << "No operation specified." << endl; + return 2; } - } catch(const runtime_error &e) { cerr << "Fatal error: " << e.what() << endl; + return 3; } }