Improve error message for duplicated items
This changes error message like below
```
ERROR at //third_party/protobuf/proto_library.gni:506:29: Duplicate item in list
public_configs += [ "${canonicalized_dep}_input_config" ]
^----------------------------------
See //third_party/protobuf/proto_library.gni:506:29: This was the previous definition.
public_configs += [ "${canonicalized_dep}_input_config" ]
^----------------------------------
...
```
to
```
ERROR at //third_party/protobuf/proto_library.gni:506:29: Duplicate item "//third_party/perfetto/protos/perfetto/trace/track_event:cpp_input_config" in list.
public_configs += [ "${canonicalized_dep}_input_config" ]
^----------------------------------
See //third_party/protobuf/proto_library.gni:506:29: This was the previous definition.
public_configs += [ "${canonicalized_dep}_input_config" ]
^----------------------------------
...
```
Change-Id: Idc08c70f04ebcd9e276c2a2e46c3434e42a599d1
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/17800
Reviewed-by: David Turner <digit@google.com>
Commit-Queue: Takuto Ikuta <tikuta@google.com>
diff --git a/src/gn/value_extractors.cc b/src/gn/value_extractors.cc
index 9eb7593..3984d22 100644
--- a/src/gn/value_extractors.cc
+++ b/src/gn/value_extractors.cc
@@ -51,7 +51,7 @@
return false;
if (!dest->push_back(new_one)) {
// Already in the list, throw error.
- *err = Err(item, "Duplicate item in list");
+ *err = Err(item, "Duplicate item " + item.ToString(true) + " in list.");
size_t previous_index = dest->IndexOf(new_one);
err->AppendSubErr(
Err(input_list[previous_index], "This was the previous definition."));