From 455ff99b9326bfbd9375abab30bc7e7181b5c0ff Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 12 Apr 2018 18:57:03 -0700 Subject: [PATCH] ircd::db: Error reporting and fallbacks for db property queries. --- ircd/db.cc | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ircd/db.cc b/ircd/db.cc index 9f657fce7..36536a5be 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -227,7 +227,12 @@ ircd::db::property(const database &cd, uint64_t ret; database &d(const_cast(cd)); if(!d.d->GetAggregatedIntProperty(slice(name), &ret)) - ret = 0; + throw not_found + { + "property '%s' for all columns in '%s' not found or not an integer.", + name, + db::name(d) + }; return ret; } @@ -3661,7 +3666,15 @@ ircd::db::property(const column &column, std::string ret; database::column &c(const_cast(column)); database &d(const_cast(column)); - d.d->GetProperty(c, slice(name), &ret); + if(!d.d->GetProperty(c, slice(name), &ret)) + throw not_found + { + "'property '%s' for column '%s' in '%s' not found.", + name, + db::name(column), + db::name(d) + }; + return ret; } @@ -3674,7 +3687,13 @@ ircd::db::property(const column &column, database::column &c(const_cast(column)); database &d(const_cast(column)); if(!d.d->GetIntProperty(c, slice(name), &ret)) - ret = 0; + throw not_found + { + "property '%s' for column '%s' in '%s' not found or not an integer.", + name, + db::name(column), + db::name(d) + }; return ret; } @@ -3687,7 +3706,9 @@ ircd::db::property(const column &column, std::map ret; database::column &c(const_cast(column)); database &d(const_cast(column)); - d.d->GetMapProperty(c, slice(name), &ret); + if(!d.d->GetMapProperty(c, slice(name), &ret)) + ret.emplace(std::string{name}, property(column, name)); + return ret; }