@@ -1419,20 +1419,26 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1419
1419
1420
1420
uiInterface.InitMessage (_ (" Loading block index…" ).translated );
1421
1421
const int64_t load_block_index_start_time = GetTimeMillis ();
1422
- auto rv = LoadChainstate (fReset ,
1423
- chainman,
1424
- Assert (node.mempool .get ()),
1425
- fPruneMode ,
1426
- chainparams,
1427
- fReindexChainState ,
1428
- nBlockTreeDBCache,
1429
- nCoinDBCache,
1430
- nCoinCacheUsage,
1431
- []() {
1432
- uiInterface.ThreadSafeMessageBox (
1433
- _ (" Error reading from database, shutting down." ),
1434
- " " , CClientUIInterface::MSG_ERROR);
1435
- });
1422
+ std::optional<ChainstateLoadingError> rv;
1423
+ try {
1424
+ rv = LoadChainstate (fReset ,
1425
+ chainman,
1426
+ Assert (node.mempool .get ()),
1427
+ fPruneMode ,
1428
+ chainparams,
1429
+ fReindexChainState ,
1430
+ nBlockTreeDBCache,
1431
+ nCoinDBCache,
1432
+ nCoinCacheUsage,
1433
+ []() {
1434
+ uiInterface.ThreadSafeMessageBox (
1435
+ _ (" Error reading from database, shutting down." ),
1436
+ " " , CClientUIInterface::MSG_ERROR);
1437
+ });
1438
+ } catch (const std::exception& e) {
1439
+ LogPrintf (" %s\n " , e.what ());
1440
+ rv = ChainstateLoadingError::ERROR_GENERIC_BLOCKDB_OPEN_FAILED;
1441
+ }
1436
1442
if (rv.has_value ()) {
1437
1443
switch (rv.value ()) {
1438
1444
case ChainstateLoadingError::ERROR_LOADING_BLOCK_DB:
@@ -1468,13 +1474,19 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1468
1474
break ;
1469
1475
}
1470
1476
} else {
1471
- uiInterface.InitMessage (_ (" Verifying blocks…" ).translated );
1472
- auto rv2 = VerifyLoadedChainstate (chainman,
1473
- fReset ,
1474
- fReindexChainState ,
1475
- chainparams,
1476
- args.GetIntArg (" -checkblocks" , DEFAULT_CHECKBLOCKS),
1477
- args.GetIntArg (" -checklevel" , DEFAULT_CHECKLEVEL));
1477
+ std::optional<ChainstateLoadVerifyError> rv2;
1478
+ try {
1479
+ uiInterface.InitMessage (_ (" Verifying blocks…" ).translated );
1480
+ rv2 = VerifyLoadedChainstate (chainman,
1481
+ fReset ,
1482
+ fReindexChainState ,
1483
+ chainparams,
1484
+ args.GetIntArg (" -checkblocks" , DEFAULT_CHECKBLOCKS),
1485
+ args.GetIntArg (" -checklevel" , DEFAULT_CHECKLEVEL));
1486
+ } catch (const std::exception& e) {
1487
+ LogPrintf (" %s\n " , e.what ());
1488
+ rv2 = ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE;
1489
+ }
1478
1490
if (rv2.has_value ()) {
1479
1491
switch (rv2.value ()) {
1480
1492
case ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE:
0 commit comments