print custom error message if type names match
parent
baaa656628
commit
14ccd06bf2
|
@ -44,7 +44,7 @@ std::string demangle(const char* name) {
|
||||||
int status = -1; // some arbitrary value to eliminate the compiler warning
|
int status = -1; // some arbitrary value to eliminate the compiler warning
|
||||||
demangled = abi::__cxa_demangle(name, nullptr, nullptr, &status),
|
demangled = abi::__cxa_demangle(name, nullptr, nullptr, &status),
|
||||||
|
|
||||||
demangled_name = (status == 0) ? std::string(demangled) : name;
|
demangled_name = (status == 0) ? std::string(demangled) : std::string(name);
|
||||||
|
|
||||||
std::free(demangled);
|
std::free(demangled);
|
||||||
|
|
||||||
|
|
|
@ -232,10 +232,21 @@ namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
const char* ValuesIncorrectType::what() const throw() {
|
const char* ValuesIncorrectType::what() const throw() {
|
||||||
if(message_.empty())
|
if(message_.empty()) {
|
||||||
|
std::string storedTypeName = demangle(storedTypeId_.name());
|
||||||
|
std::string requestedTypeName = demangle(requestedTypeId_.name());
|
||||||
|
|
||||||
|
if (storedTypeName == requestedTypeName) {
|
||||||
|
message_ = "WARNING: Detected types with same name but different `typeid`. \
|
||||||
|
This is usually caused by incorrect linking/inlining settings when compiling libraries using GTSAM. \
|
||||||
|
If you are a user, please report to the author of the library using GTSAM. \
|
||||||
|
If you are a package maintainer, please consult `cmake/GtsamPybindWrap.cmake`, line 74 for details.";
|
||||||
|
} else {
|
||||||
message_ =
|
message_ =
|
||||||
"Attempting to retrieve value with key \"" + DefaultKeyFormatter(key_) + "\", type stored in Values is " +
|
"Attempting to retrieve value with key \"" + DefaultKeyFormatter(key_) + "\", type stored in Values is " +
|
||||||
std::string(demangle(storedTypeId_.name())) + " but requested type was " + std::string(demangle(requestedTypeId_.name()));
|
storedTypeName + " but requested type was " + requestedTypeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
return message_.c_str();
|
return message_.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue