From 202fd93c9dafb6844236ca6c20731f886d85f8e1 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Fri, 10 Jun 2016 11:30:23 -0700 Subject: [PATCH] Better handling of DB errors, in case the DB is at least partly readable. I've only ever seen this happen once, btw, on a machine w/ flaky failing memory. --- src/db/hierdatabase.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/db/hierdatabase.cpp diff --git a/src/db/hierdatabase.cpp b/src/db/hierdatabase.cpp old mode 100644 new mode 100755 index 8c98ea3..2a88614 --- a/src/db/hierdatabase.cpp +++ b/src/db/hierdatabase.cpp @@ -39,6 +39,7 @@ #include "core/archive.h" #include "core/upperbound.h" #include "core/errorbucket.h" +#include "core/errorbucketimpl.h" // TODO -- all of these util_ functions should throw an eArchive if an attempt is made to // write to a null address @@ -288,7 +289,19 @@ void cHierDatabaseIter::LoadArrayAt(const cHierAddr& addr) //throw (eArchive, eH while( ! curAddr.IsNull() ) { mEntries.push_back( cHierEntry() ); - util_ReadObject( mpDb, &mEntries.back(), curAddr ); + //Catch db errors, in case only part of db is broken + try + { + util_ReadObject( mpDb, &mEntries.back(), curAddr ); + } + catch( eError& e ) + { + e.SetFatality(false); + cErrorReporter::PrintErrorMsg(e); + mEntries.pop_back(); + break; + } + curAddr = mEntries.back().mNext; }