tesseract-robotics / tesseract

Motion Planning Environment
http://tesseract-docs.rtfd.io
Other
257 stars 89 forks source link

Add backtrace to type erasure casting to quickly identify where the issue location #1012

Closed Levi-Armstrong closed 3 months ago

Levi-Armstrong commented 3 months ago

Now when you have an invalid cast exception with the type erasure you will get a detailed backtrace like what is shown below.

C++ exception with description "TypeErasureBase, tried to cast 'N16tesseract_common10JointStateE' to 'd'
Backtrace:
 0# double& tesseract_common::TypeErasureBase<tesseract_common::TypeErasureInterface, tesseract_common::detail_any::AnyInstance>::as<double>() at ~/catkin_ws/tesseract_ws/src/tesseract-1/tesseract_common/include/tesseract_common/type_erasure.h:225
 1# TesseractCommonUnit_anyUnit_Test::TestBody() at ~/catkin_ws/tesseract_ws/src/tesseract-1/tesseract_common/test/tesseract_common_unit.cpp:378
 2# void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) at ./googletest/src/gtest.cc:2493
 3# testing::Test::Run() at ./googletest/src/gtest.cc:2498
 4# testing::TestInfo::Run() at ./googletest/src/gtest.cc:2657
 5# testing::TestSuite::Run() at ./googletest/src/gtest.cc:2795
 6# testing::internal::UnitTestImpl::RunAllTests() at ./googletest/src/gtest.cc:5336
 7# bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) at ./googletest/src/gtest.cc:2493
 8# testing::UnitTest::Run() at ./googletest/src/gtest.cc:4928
 9# main at ~/catkin_ws/tesseract_ws/src/tesseract-1/tesseract_common/test/tesseract_common_unit.cpp:2479
10# __libc_start_main at ../csu/libc-start.c:342
11# _start in ./tesseract_common_unit
codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.13%. Comparing base (6f9582d) to head (de8b39d).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/tesseract-robotics/tesseract/pull/1012/graphs/tree.svg?width=650&height=150&src=pr&token=nh4aHZzgpR&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tesseract-robotics)](https://app.codecov.io/gh/tesseract-robotics/tesseract/pull/1012?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tesseract-robotics) ```diff @@ Coverage Diff @@ ## master #1012 +/- ## ========================================== - Coverage 90.13% 90.13% -0.01% ========================================== Files 280 280 Lines 15859 15859 ========================================== - Hits 14295 14294 -1 - Misses 1564 1565 +1 ``` [see 3 files with indirect coverage changes](https://app.codecov.io/gh/tesseract-robotics/tesseract/pull/1012/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tesseract-robotics)
Levi-Armstrong commented 3 months ago

@johnwason Do you know why the if(WIN32) is not working, because it is still adding the other boost library?

marip8 commented 3 months ago

It would be nice to add demangling to the class names to make the output more readable. That should be available in boost and I think also in the C++ STL

Levi-Armstrong commented 3 months ago

It would be nice to add demangling to the class names to make the output more readable. That should be available in boost and I think also in the C++ STL

New output

C++ exception with description "TypeErasureBase, tried to cast 'tesseract_common::JointState' to 'double'