{
case PB_HTYPE_REQUIRED:
if (!pData)
- return false;
+ PB_RETURN_ERROR(stream, "missing required field");
if (!pb_encode_tag_for_field(stream, field))
return false;
if (!func(stream, field, pData))
bool status;
if (!pb_encode(&substream, fields, src_struct))
+ {
+#ifndef PB_NO_ERRMSG
+ stream->errmsg = substream.errmsg;
+#endif
return false;
+ }
size = substream.bytes_written;