-
Notifications
You must be signed in to change notification settings - Fork 0
Description
This issue was copied from the upstream repository google/emboss.
Original issue: google#27
Original state: open, created at: 2022-02-15T22:47:57Z, updated at: 2024-12-18T23:15:24Z, by @reventlov
Original description
UpdateFromText() just returns a bool indicating success/failure. There is currently no way to find out where parsing failed, which makes it difficult to debug manually-written text format structs.
Discussion (copied comments)
Comment by @reventlov on 2023-05-04T23:55:45Z:
The implementation of this is probably to update the C++ UpdateFromTextStream() methods to take an optional output parameter, or to build a parallel API like UpdateFromTextStreamOrReturnError(). I haven't given a lot of thought to the best way to actually return the error(s). Right now, the update bails out if there is any error, but I can imagine having an allow_partial_update option similar to the allow_partial_output option for text output, so ideally the API would allow multiple errors to be returned.
A (maybe) comprehensive list of the places that are are likely to need to be changed:
UpdateFromTextStream()on generated structure (structandbits) views; tests in text_format_test.cc, nested_structure_test.cc, bits_test.cc, anonymous_bits_test.cc, uint_sizes_test.cc, and complex_structure_test.ccUpdateFromTextStream()on virtual fields; tests in virtual_field_test.ccUpdateFromTextStream()on arrays, which really just callsReadArrayFromTextStream(); tests in emboss_array_view_test.ccUpdateFromTextStream()onenum; tests in emboss_enum_view_test.ccUpdateFromTextStream()on built-in types:Flag,UInt,Int,Bcd, andFloat; tests are all in emboss_prelude_test.cc- The
UpdateFromTextconvenience function should also get an optional parameter or alternate API. - There are references to
UpdateFromTextorUpdateFromTextStreamin text-format.md, cpp-guide.md, and cpp-reference.md.