Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions all reported as "Unknown exception" #1924

Closed
claremacrae opened this issue May 8, 2020 · 2 comments
Closed

Exceptions all reported as "Unknown exception" #1924

claremacrae opened this issue May 8, 2020 · 2 comments

Comments

@claremacrae
Copy link
Contributor

claremacrae commented May 8, 2020

Describe the bug

Catch2 does not report the text of unexpected exceptions (ex.what()) on the console.

Expected behavior

If exceptions are enabled, and code in a TEST_CASE throws an exception derived from std::exception, the exception.what() text should be displayed to the user.

Actual behavior
The following is displayed:

Failure:
unexpected exception
Process finished with exit code 1

Reproduction steps

main.cpp

#define CATCH_CONFIG_MAIN
#include "catch2/catch.v2.11.0.hpp"

Catch2Tests.cpp

#include "catch2/catch.v2.11.0.hpp"

#include <exception>

TEST_CASE("TestStreamableObject")
{
    throw std::runtime_error("I should be printed");
}

CMakeLists.txt

project(catch2_only)
set(CMAKE_CXX_STANDARD 11)
add_executable(${PROJECT_NAME}
        main.cpp
        Catch2Tests.cpp
        )
target_link_libraries(${PROJECT_NAME} Catch2::Catch2)

add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})

Platform information:

  • OS: macOS Catalina 10.15.4
  • Compiler+version: Xcode C++ compiler, g++9, clang-9
  • Catch version: v2.11.0

Additional context

  • I believe this has been reported before, in Exceptions all reported as "Unknown exception" #463
  • This has been seen by multiple users of ApprovalTests.cpp, on multiple different machines
  • It's reproducible with the Xcode C++ compiler, g++9, clang-9
  • I'm building in CLion, but I don't see why that would matter
  • I cannot seen anywhere in the Catch2 source code that prints out just unexpected exception - so I am stumped as to where this comes from
  • I've gone back through multiple old catch releases, back to v2.0.1 - and have not been able to get the exception text to print
  • But I swear that I previously was able to get exception text displayed
  • I paired with someone else who saw this on their Mac, with a similarly minimal example - and they switched to Windows and the same code did display the exception text
  • So I suspect it may be a Mac-specific issue (but compiler-independent - I've been working on Mac for less than a year)
@claremacrae
Copy link
Contributor Author

Eventually it dawned on me to run the Catch2 program in the console, and it ran fine and showed the exception text.

So I asked Phil Nash about it, and he pointed me to the 2-year old CLion issue about this:
https://youtrack.jetbrains.com/issue/CPP-11919

So I'm closing this, as it's not a Catch2 issue...

@claremacrae
Copy link
Contributor Author

For info, the underlying CLion issue mentioned above has been fixed in CLion release 2020.2 (available via Early Access Program as of early July 2020)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants