Skip to content

Commit

Permalink
libtrellis: Improve error handling
Browse files Browse the repository at this point in the history
Signed-off-by: David Shah <dave@ds0.me>
  • Loading branch information
gatecat committed Oct 25, 2019
1 parent 72fe507 commit 912140b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libtrellis/src/BitDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ void TileBitDatabase::config_to_tile_cram(const TileConfig &cfg, CRAMView &tile,
if (ce.name.substr(0, base_prefix.length()) == base_prefix) {
if (is_tilegroup && !enums.count(ce.name))
continue;
else if (!enums.count(ce.name))
throw std::runtime_error("no enum named '" + ce.name + "'");
if (is_tilegroup && !enums.at(ce.name).options.count(ce.value))
continue;
if (tg_matches)
Expand All @@ -356,6 +358,8 @@ void TileBitDatabase::config_to_tile_cram(const TileConfig &cfg, CRAMView &tile,
for (auto cw : cfg.cwords) {
if (is_tilegroup && !words.count(cw.name))
continue;
if (!words.count(cw.name))
throw std::runtime_error("no word named '" + cw.name + "'");
if (tg_matches)
tg_matches->insert(cw.name);
words.at(cw.name).set_value(tile, cw.value);
Expand All @@ -365,6 +369,8 @@ void TileBitDatabase::config_to_tile_cram(const TileConfig &cfg, CRAMView &tile,
if (ce.name.substr(0, base_prefix.length()) != base_prefix) {
if (is_tilegroup && !enums.count(ce.name))
continue;
else if (!enums.count(ce.name))
throw std::runtime_error("no enum named '" + ce.name + "'");
if (is_tilegroup && !enums.at(ce.name).options.count(ce.value))
continue;
if (tg_matches)
Expand Down

0 comments on commit 912140b

Please sign in to comment.