2
2
3
3
#include < algorithm>
4
4
#include < chrono>
5
+ #include < iostream>
5
6
#include < iterator>
7
+ #include < sstream>
6
8
#include < stdexcept>
7
9
#include < tuple>
8
10
@@ -108,8 +110,15 @@ Family<T>& Registry::Add(const std::string& name, const std::string& help,
108
110
std::lock_guard<std::mutex> lock{mutex_};
109
111
110
112
if (NameExistsInOtherType<T>(name)) {
111
- throw std::invalid_argument (
112
- " Family name already exists with different type" );
113
+ std::stringstream ss;
114
+ ss << " Family name already exists with different type (name:'" << name
115
+ << " ',type:'" << typeid (T).name () << " ');help:" << help << " ;labels:" ;
116
+ for (const auto & label : labels) {
117
+ ss << label.first << " =" << label.second << " ," ;
118
+ }
119
+ ss << std::endl;
120
+ std::cerr << ss.str ();
121
+ throw std::invalid_argument (ss.str ());
113
122
}
114
123
115
124
auto & families = GetFamilies<T>();
@@ -134,7 +143,15 @@ Family<T>& Registry::Add(const std::string& name, const std::string& help,
134
143
135
144
auto it = std::find_if (families.begin (), families.end (), same_name);
136
145
if (it != families.end ()) {
137
- throw std::invalid_argument (" Family name already exists" );
146
+ std::stringstream ss;
147
+ ss << " Family name already exists (name:'" << name
148
+ << " ',type:'" << typeid (T).name () << " ');help:" << help << " ;labels:" ;
149
+ for (const auto & label : labels) {
150
+ ss << label.first << " =" << label.second << " ," ;
151
+ }
152
+ ss << std::endl;
153
+ std::cerr << ss.str ();
154
+ throw std::invalid_argument (ss.str ());
138
155
}
139
156
140
157
auto family = detail::make_unique<Family<T>>(name, help, labels, ttl);
0 commit comments