MCPcopy Create free account
hub / github.com/Snapchat/Valdi / makeParseError

Method makeParseError

valdi_core/src/valdi_core/cpp/Utils/TextParser.cpp:304–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304Error TextParser::makeParseError(std::string_view str, std::string_view sourceErrorMessage, size_t position) {
305 SC_ASSERT(position <= str.size());
306 auto targetEndPosition = position + kMaxErrorMessageLength;
307 auto resolvedEndPosition = std::min(str.size(), targetEndPosition);
308
309 auto debugString = str.substr(position, resolvedEndPosition - position);
310
311 std::string suffix;
312 if (debugString.empty()) {
313 suffix = "<EOF>";
314 } else {
315 suffix = debugString;
316 if (debugString.size() != str.size() - position) {
317 suffix += "…";
318 }
319 }
320
321 return Error(STRING_FORMAT("At position {} ({}): {}", position, suffix, sourceErrorMessage));
322}
323
324} // namespace Valdi

Callers

nothing calls this directly

Calls 5

minFunction · 0.85
substrMethod · 0.80
ErrorClass · 0.70
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected