aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-02-26 13:23:52 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-02-26 13:23:52 +0100
commit44235713ed0ad1810328f21108d32bbac04de87b (patch)
treeb76a7b63c32f9e8dcc6b9af6b96ae4b493b9fcf8
parent3480bf7c650bb14a31020c3ef33e76edea650e13 (diff)
downloadbitcoin-44235713ed0ad1810328f21108d32bbac04de87b.tar.xz
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)
-rw-r--r--src/rpcclient.cpp3
-rw-r--r--src/util.cpp9
-rw-r--r--src/util.h13
3 files changed, 10 insertions, 15 deletions
diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp
index 0d1746b8ca..37a501bb17 100644
--- a/src/rpcclient.cpp
+++ b/src/rpcclient.cpp
@@ -236,7 +236,8 @@ int CommandLineRPC(int argc, char *argv[])
nRet = abs(RPC_MISC_ERROR);
}
catch (...) {
- PrintException(NULL, "CommandLineRPC()");
+ PrintExceptionContinue(NULL, "CommandLineRPC()");
+ throw;
}
if (strPrint != "")
diff --git a/src/util.cpp b/src/util.cpp
index 8cfd1c2e03..0cc472ac97 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -948,15 +948,6 @@ void LogException(std::exception* pex, const char* pszThread)
LogPrintf("\n%s", message);
}
-void PrintException(std::exception* pex, const char* pszThread)
-{
- std::string message = FormatException(pex, pszThread);
- LogPrintf("\n\n************************\n%s\n", message);
- fprintf(stderr, "\n\n************************\n%s\n", message.c_str());
- strMiscWarning = message;
- throw;
-}
-
void PrintExceptionContinue(std::exception* pex, const char* pszThread)
{
std::string message = FormatException(pex, pszThread);
diff --git a/src/util.h b/src/util.h
index 6ef93021fd..8b1b7cd2aa 100644
--- a/src/util.h
+++ b/src/util.h
@@ -172,7 +172,6 @@ static inline bool error(const char* format)
void LogException(std::exception* pex, const char* pszThread);
-void PrintException(std::exception* pex, const char* pszThread);
void PrintExceptionContinue(std::exception* pex, const char* pszThread);
void ParseString(const std::string& str, char c, std::vector<std::string>& v);
std::string FormatMoney(int64_t n, bool fPlus=false);
@@ -566,10 +565,12 @@ template <typename Callable> void LoopForever(const char* name, Callable func,
throw;
}
catch (std::exception& e) {
- PrintException(&e, name);
+ PrintExceptionContinue(&e, name);
+ throw;
}
catch (...) {
- PrintException(NULL, name);
+ PrintExceptionContinue(NULL, name);
+ throw;
}
}
// .. and a wrapper that just calls func once
@@ -589,10 +590,12 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
throw;
}
catch (std::exception& e) {
- PrintException(&e, name);
+ PrintExceptionContinue(&e, name);
+ throw;
}
catch (...) {
- PrintException(NULL, name);
+ PrintExceptionContinue(NULL, name);
+ throw;
}
}