Skip to content
Permalink
Browse files

Database: Display error message if tags database is not in expected f…

…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 Jan 4, 2019
1 parent 7c5503f commit 465d3bd676a70ebca69c9a4d9d5f3222dd0010dc
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/Database.cpp
@@ -372,8 +372,10 @@ void Database::initializeTagDatabase ()
{
auto key = pair.first;
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});
}
}

0 comments on commit 465d3bd

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.