Skip to content

Commit

Permalink
Database: Display error message if tags database is not in expected f…
Browse files Browse the repository at this point in the history
…ormat.

Had an early tags database conversion script that was not labeling the tag
counts with "count". Instead of a segfault, this prints an error message to
hopefully point the user in the correct location to look for the error.
  • Loading branch information
sruffell authored and lauft committed Feb 26, 2019
1 parent 7c5503f commit 465d3bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Database.cpp
Expand Up @@ -372,8 +372,10 @@ void Database::initializeTagDatabase ()
{ {
auto key = pair.first; auto key = pair.first;
auto* value = (json::object*) pair.second; auto* value = (json::object*) pair.second;
auto* number = (json::number*) value->_data["count"]; auto iter = value->_data.find ("count");

if (iter == value->_data.end ())
throw format ("Failed to find \"count\" member for tag \"{1}\" in tags database. Database corrupted?", key);
auto number = static_cast<json::number *> (iter->second);
_tagInfoDatabase.add (key, TagInfo {(unsigned int) number->_dvalue}); _tagInfoDatabase.add (key, TagInfo {(unsigned int) number->_dvalue});
} }
} }
Expand Down

0 comments on commit 465d3bd

Please sign in to comment.