@@ -696,7 +696,7 @@ static void replaceColors(std::string& source, bool erase) {
696696 replace (source, substitutionMapErase);
697697}
698698
699- std::string ErrorMessage::toString (bool verbose, const std::string &templateFormat, const std::string &templateLocation) const
699+ std::string ErrorMessage::toString (bool verbose, const std::string &templateFormat, const std::string &templateLocation, bool noCode ) const
700700{
701701 assert (!templateFormat.empty ());
702702
@@ -737,7 +737,8 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
737737 endl = " \r\n " ;
738738 else
739739 endl = " \r " ;
740- findAndReplace (result, " {code}" , readCode (callStack.back ().getOrigFile (), callStack.back ().line , callStack.back ().column , endl));
740+ const std::string code = noCode ? " " : readCode (callStack.back ().getOrigFile (), callStack.back ().line , callStack.back ().column , endl);
741+ findAndReplace (result, " {code}" , code);
741742 }
742743 } else {
743744 static const std::unordered_map<std::string, std::string> callStackSubstitutionMap =
@@ -768,7 +769,8 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
768769 endl = " \r\n " ;
769770 else
770771 endl = " \r " ;
771- findAndReplace (text, " {code}" , readCode (fileLocation.getOrigFile (), fileLocation.line , fileLocation.column , endl));
772+ const std::string code = noCode ? " " : readCode (callStack.back ().getOrigFile (), callStack.back ().line , callStack.back ().column , endl);
773+ findAndReplace (text, " {code}" , code);
772774 }
773775 result += ' \n ' + text;
774776 }
0 commit comments