| 219 | } |
| 220 | |
| 221 | void ErrorMessage::setmsg(const std::string &msg) |
| 222 | { |
| 223 | // If a message ends to a '\n' and contains only a one '\n' |
| 224 | // it will cause the mVerboseMessage to be empty which will show |
| 225 | // as an empty message to the user if --verbose is used. |
| 226 | // Even this doesn't cause problems with messages that have multiple |
| 227 | // lines, none of the error messages should end into it. |
| 228 | assert(!endsWith(msg,'\n')); |
| 229 | |
| 230 | // The summary and verbose message are separated by a newline |
| 231 | // If there is no newline then both the summary and verbose messages |
| 232 | // are the given message |
| 233 | const std::string::size_type pos = msg.find('\n'); |
| 234 | const std::string symbolName = mSymbolNames.empty() ? std::string() : mSymbolNames.substr(0, mSymbolNames.find('\n')); |
| 235 | if (pos == std::string::npos) { |
| 236 | mShortMessage = replaceStr(msg, "$symbol", symbolName); |
| 237 | mVerboseMessage = replaceStr(msg, "$symbol", symbolName); |
| 238 | } else if (startsWith(msg,"$symbol:")) { |
| 239 | mSymbolNames += msg.substr(8, pos-7); |
| 240 | setmsg(msg.substr(pos + 1)); |
| 241 | } else { |
| 242 | mShortMessage = replaceStr(msg.substr(0, pos), "$symbol", symbolName); |
| 243 | mVerboseMessage = replaceStr(msg.substr(pos + 1), "$symbol", symbolName); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | static void serializeString(std::string &oss, const std::string & str) |
| 248 | { |
no test coverage detected