Ignore:
Timestamp:
09/27/17 22:36:57 (5 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master
Children:
01d1452
Parents:
961971e
git-author:
Philipp Spitzer <philipp@…> (09/27/17 22:20:05)
git-committer:
Philipp Spitzer <philipp@…> (09/27/17 22:36:57)
Message:

Now using exceptions to report errors in schedulexmlparser.cpp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sql/schedulexmlparser.cpp

    r961971e r9782bbb  
    3333
    3434
     35class ParseException: public std::runtime_error {
     36public:
     37    ParseException(const QString& message): std::runtime_error(message.toStdString()) {}
     38};
     39
     40
    3541void ScheduleXmlParser::parseDataImpl(const QByteArray &aData, const QString& url, int conferenceId) {
    3642    QDomDocument document;
     
    3844    int xml_error_line;
    3945    int xml_error_column;
    40     if (!document.setContent (aData, false, &xml_error, &xml_error_line, &xml_error_column)) {
    41         error_message("Could not parse schedule: " + xml_error + " at line " + QString("%1").arg(xml_error_line) + " column " + QString("%1").arg(xml_error_column));
    42         return;
     46    if (!document.setContent(aData, false, &xml_error, &xml_error_line, &xml_error_column)) {
     47        throw ParseException("Could not parse schedule: " + xml_error + " at line " + QString("%1").arg(xml_error_line) + " column " + QString("%1").arg(xml_error_column));
    4348    }
    4449
     
    166171        } // parsing day elements
    167172    } // schedule element
    168     if (!conference_title.isNull()) {
    169         transaction.commit();
    170         emit parsingScheduleEnd(conferenceId);
    171     } else {
    172         error_message("Could not parse schedule");
    173     }
     173    if (conference_title.isNull()) throw ParseException("Could not parse schedule");
     174
     175    transaction.commit();
     176    emit parsingScheduleEnd(conferenceId);
    174177}
    175178
    176179
    177180void ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url, int conferenceId) {
    178     parseDataImpl(aData, url, conferenceId);
     181    try {
     182        parseDataImpl(aData, url, conferenceId);
     183    } catch (ParseException& e) {
     184        error_message(e.what());
     185    }
    179186}
    180187
Note: See TracChangeset for help on using the changeset viewer.