Put field name in error message for set duplication check on write
Client: go
Before:
thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("%T error writing set field: slice is not unique", p.Foo))
After:
thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("%T error writing set field %q: slice is not unique", p.Foo, "p.Foo"))
Currently when there are more than one field inside a struct being sets
and this error happens, it's impossible to tell which field contains
duplications to cause this error.
diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc
index 8d05892..bef2855 100644
--- a/compiler/cpp/src/thrift/generate/t_go_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc
@@ -3747,8 +3747,8 @@
out << indent() << "}(" << wrapped_prefix << "[i], " << wrapped_prefix << "[j]) {" << '\n';
indent_up();
out << indent() << "return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, "
- << "fmt.Errorf(\"%T error writing set field: slice is not " "unique\", "
- << wrapped_prefix << "))" << '\n';
+ << "fmt.Errorf(\"%T error writing set field %q: slice is not unique\", "
+ << wrapped_prefix << ", \"" << escape_string(prefix) << "\"))" << '\n';
indent_down();
out << indent() << "}" << '\n';
indent_down();