Skip to content

Commit

Permalink
handle XML parsing errors when loading the external channel map
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Jun 15, 2015
1 parent 2273819 commit e63005c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/vbox/GuideChannelMapper.cpp
Expand Up @@ -22,6 +22,7 @@
#include "GuideChannelMapper.h"
#include <memory>
#include "lib/tinyxml2/tinyxml2.h"
#include "Exceptions.h"
#include "Utilities.h"
#include "../client.h"

Expand Down Expand Up @@ -79,10 +80,13 @@ void GuideChannelMapper::Load()

if (fileHandle)
{
// Parse the document
// Read the XML
tinyxml2::XMLDocument document;
std::unique_ptr<std::string> contents = utilities::ReadFileContents(fileHandle);
document.Parse(contents->c_str());

// Try to parse the document
if (document.Parse(contents->c_str(), contents->size()) != XML_NO_ERROR)
throw vbox::InvalidXMLException("XML parsing failed: " + std::string(document.ErrorName()));

// Create mappings
for (const XMLElement *element = document.RootElement()->FirstChildElement("mapping");
Expand Down

0 comments on commit e63005c

Please sign in to comment.