22
33#include < algorithm>
44#include < chrono>
5+ #include < iostream>
56#include < iterator>
7+ #include < sstream>
68#include < stdexcept>
79#include < tuple>
810
@@ -108,8 +110,15 @@ Family<T>& Registry::Add(const std::string& name, const std::string& help,
108110 std::lock_guard<std::mutex> lock{mutex_};
109111
110112 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 ());
113122 }
114123
115124 auto & families = GetFamilies<T>();
@@ -134,7 +143,15 @@ Family<T>& Registry::Add(const std::string& name, const std::string& help,
134143
135144 auto it = std::find_if (families.begin (), families.end (), same_name);
136145 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 ());
138155 }
139156
140157 auto family = detail::make_unique<Family<T>>(name, help, labels, ttl);
0 commit comments