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

Method onDecodeError

valdi_protobuf/src/valdi_protobuf/Message.cpp:299–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299bool Message::onDecodeError(
300 std::string_view message, int fieldNumber, const Byte* data, size_t length, ExceptionTracker& exceptionTracker) {
301 auto descriptorName = _descriptor != nullptr ? _descriptor->full_name() : "<Unknown>";
302 std::string errorMessage =
303 fmt::format("In message type '{}' and field number {}: {}", descriptorName, fieldNumber, message);
304
305 if (snap::kIsDevBuild || snap::kIsGoldBuild) {
306 auto logger = Valdi::strongSmallRef(kLogger);
307 if (logger != nullptr) {
308 VALDI_ERROR(*logger, "Message failed to decode: {}", errorMessage);
309 VALDI_ERROR(
310 *logger, "{} payload content: {}", descriptorName, snap::utils::encoding::binaryToBase64(data, length));
311 }
312 }
313
314 exceptionTracker.onError(std::move(errorMessage));
315 return false;
316}
317
318bool Message::decode(const Byte* data, size_t length, ExceptionTracker& exceptionTracker) {
319 google::protobuf::io::CodedInputStream inputStream(data, static_cast<int>(length));

Callers

nothing calls this directly

Calls 3

strongSmallRefFunction · 0.85
binaryToBase64Function · 0.85
onErrorMethod · 0.65

Tested by

no test coverage detected