Skip to content

Commit 4423571

Browse files
committed
Replace PrintException with PrintExceptionContinue + throw
Just a pet peeve. (PrintException has exactly the same body as PrintExceptionContinue but does a re-throw at the end. Move these re-throws to the call site, this aids understanding what is going on as well as eliminates a bit of code duplication in util.cpp)
1 parent 3480bf7 commit 4423571

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

src/rpcclient.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ int CommandLineRPC(int argc, char *argv[])
236236
nRet = abs(RPC_MISC_ERROR);
237237
}
238238
catch (...) {
239-
PrintException(NULL, "CommandLineRPC()");
239+
PrintExceptionContinue(NULL, "CommandLineRPC()");
240+
throw;
240241
}
241242

242243
if (strPrint != "")

src/util.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -948,15 +948,6 @@ void LogException(std::exception* pex, const char* pszThread)
948948
LogPrintf("\n%s", message);
949949
}
950950

951-
void PrintException(std::exception* pex, const char* pszThread)
952-
{
953-
std::string message = FormatException(pex, pszThread);
954-
LogPrintf("\n\n************************\n%s\n", message);
955-
fprintf(stderr, "\n\n************************\n%s\n", message.c_str());
956-
strMiscWarning = message;
957-
throw;
958-
}
959-
960951
void PrintExceptionContinue(std::exception* pex, const char* pszThread)
961952
{
962953
std::string message = FormatException(pex, pszThread);

src/util.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ static inline bool error(const char* format)
172172

173173

174174
void LogException(std::exception* pex, const char* pszThread);
175-
void PrintException(std::exception* pex, const char* pszThread);
176175
void PrintExceptionContinue(std::exception* pex, const char* pszThread);
177176
void ParseString(const std::string& str, char c, std::vector<std::string>& v);
178177
std::string FormatMoney(int64_t n, bool fPlus=false);
@@ -566,10 +565,12 @@ template <typename Callable> void LoopForever(const char* name, Callable func,
566565
throw;
567566
}
568567
catch (std::exception& e) {
569-
PrintException(&e, name);
568+
PrintExceptionContinue(&e, name);
569+
throw;
570570
}
571571
catch (...) {
572-
PrintException(NULL, name);
572+
PrintExceptionContinue(NULL, name);
573+
throw;
573574
}
574575
}
575576
// .. and a wrapper that just calls func once
@@ -589,10 +590,12 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
589590
throw;
590591
}
591592
catch (std::exception& e) {
592-
PrintException(&e, name);
593+
PrintExceptionContinue(&e, name);
594+
throw;
593595
}
594596
catch (...) {
595-
PrintException(NULL, name);
597+
PrintExceptionContinue(NULL, name);
598+
throw;
596599
}
597600
}
598601

0 commit comments

Comments
 (0)