Skip to content

Commit 1423b02

Browse files
committed
errorlogger.cpp: use substitution map when no callstack exists
1 parent 4415096 commit 1423b02

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

lib/errorlogger.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,15 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
627627
findAndReplace(result, "{code}", readCode(callStack.back().getOrigFile(), callStack.back().line, callStack.back().column, endl));
628628
}
629629
} else {
630-
findAndReplace(result, "{callstack}", emptyString);
631-
findAndReplace(result, "{file}", "nofile");
632-
findAndReplace(result, "{line}", "0");
633-
findAndReplace(result, "{column}", "0");
634-
findAndReplace(result, "{code}", emptyString);
630+
static const std::unordered_map<std::string, std::string> callStackSubstitutionMap =
631+
{
632+
{"{callstack}", ""},
633+
{"{file}", "nofile"},
634+
{"{line}", "0"},
635+
{"{column}", "0"},
636+
{"{code}", ""}
637+
};
638+
replace(result, callStackSubstitutionMap);
635639
}
636640

637641
if (!templateLocation.empty() && callStack.size() >= 2U) {

0 commit comments

Comments
 (0)