Skip to content

Commit d172b5c

Browse files
committed
Add InitError(error, details) overload
This is only used in the current PR to avoid ugly `strprintf(Untranslated("%s:\n%s"), str, MakeUnorderedList(details)` boilerplate in init code. But in the future the function could be extended and more widely used to include more details in GUI error messages or display them in a more readable way, see code comment.
1 parent 3db2874 commit d172b5c

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

src/index/base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static void FatalError(const char* fmt, const Args&... args)
3535
std::string strMessage = tfm::format(fmt, args...);
3636
SetMiscWarning(Untranslated(strMessage));
3737
LogPrintf("*** %s\n", strMessage);
38-
AbortError(_("A fatal internal error occurred, see debug.log for details"));
38+
InitError(_("A fatal internal error occurred, see debug.log for details"));
3939
StartShutdown();
4040
}
4141

src/node/interface_ui.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <node/interface_ui.h>
66

7+
#include <util/string.h>
78
#include <util/translation.h>
89

910
#include <boost/signals2/optional_last_value.hpp>
@@ -62,6 +63,18 @@ bool InitError(const bilingual_str& str)
6263
return false;
6364
}
6465

66+
bool InitError(const bilingual_str& str, const std::vector<std::string>& details)
67+
{
68+
// For now just flatten the list of error details into a string to pass to
69+
// the base InitError overload. In the future, if more init code provides
70+
// error details, the details could be passed separately from the main
71+
// message for rich display in the GUI. But currently the only init
72+
// functions which provide error details are ones that run during early init
73+
// before the GUI uiInterface is registered, so there's no point passing
74+
// main messages and details separately to uiInterface yet.
75+
return InitError(details.empty() ? str : strprintf(Untranslated("%s:\n%s"), str, MakeUnorderedList(details)));
76+
}
77+
6578
void InitWarning(const bilingual_str& str)
6679
{
6780
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);

src/node/interface_ui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void InitWarning(const bilingual_str& str);
116116

117117
/** Show error message **/
118118
bool InitError(const bilingual_str& str);
119-
constexpr auto AbortError = InitError;
119+
bool InitError(const bilingual_str& str, const std::vector<std::string>& details);
120120

121121
extern CClientUIInterface uiInterface;
122122

src/shutdown.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bool AbortNode(const std::string& strMessage, bilingual_str user_message)
2727
if (user_message.empty()) {
2828
user_message = _("A fatal internal error occurred, see debug.log for details");
2929
}
30-
AbortError(user_message);
30+
InitError(user_message);
3131
StartShutdown();
3232
return false;
3333
}

0 commit comments

Comments
 (0)