Skip to content

Commit

Permalink
Fix conversion file parsing error handling in `Editor::convert_tiles_…
Browse files Browse the repository at this point in the history
…by_file`
  • Loading branch information
Vankata453 authored Oct 22, 2024
1 parent a6f734d commit b7f9a47
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,27 +727,22 @@ Editor::convert_tiles_by_file(const std::string& file)
{
IFileStream in(file);
if (!in.good())
{
log_warning << "Couldn't open conversion file '" << file << "'." << std::endl;
return;
}
throw std::runtime_error("Error opening file stream!");

int a, b;
std::string delimiter;
while (in >> a >> delimiter >> b)
{
if (delimiter != "->")
{
log_warning << "Couldn't parse conversion file '" << file << "'." << std::endl;
return;
}
throw std::runtime_error("Expected '->' delimiter!");

tiles[a] = b;
}
}
catch (std::exception& err)
{
log_warning << "Couldn't parse conversion file '" << file << "': " << err.what() << std::endl;
return;
}

for (const auto& sector : m_level->get_sectors())
Expand Down

0 comments on commit b7f9a47

Please sign in to comment.