diff options
Diffstat (limited to 'LoadFilesCommand.cpp')
-rw-r--r-- | LoadFilesCommand.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/LoadFilesCommand.cpp b/LoadFilesCommand.cpp index 3fb4978..76cd197 100644 --- a/LoadFilesCommand.cpp +++ b/LoadFilesCommand.cpp @@ -1,3 +1,4 @@ +#include <memory> #include <vector> #include <string> @@ -27,12 +28,15 @@ void LoadFilesCommand::load_files() { ToggleMuseumPauseCommand(this->museum, true).execute(); MuseumDeserializer deserializer { this->museum }; + ParserFactory factory {}; + for (string url : files) { - unique_ptr<FileReader> file = FileReaderFactory().create(url); try { - ParserFactory::parse(*file, deserializer); + unique_ptr<FileReader> file = FileReaderFactory().create(url); + Parser & parser = factory.get_parser(*file); + parser.parse(deserializer); } catch (Exception & e) { - throw Exception("parser error: %s (%s)", e.what(), url.c_str()); + throw Exception("%s (%s)", e.what(), url.c_str()); } } } @@ -41,7 +45,7 @@ void LoadFilesCommand::execute() { try { this->load_files(); } catch (Exception & e) { - throw Exception("LoadFilesCommand error: %s", e.what()); + throw Exception("LoadFilesCommand: %s", e.what()); } } |