Skip to content

Commit

Permalink
more information when catching std::exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgtdf committed Jun 14, 2017
1 parent 2eaf65b commit 2cf7858
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wesnoth.cpp
Expand Up @@ -1098,9 +1098,9 @@ int main(int argc, char** argv)
std::cerr << "Ran out of memory. Aborted.\n";
error_exit(ENOMEM);
#if !defined(NO_CATCH_AT_GAME_END)
} catch(std::exception & e) {
} catch(const std::exception & e) {
// Try to catch unexpected exceptions.
std::cerr << "Caught general exception:\n" << e.what() << std::endl;
std::cerr << "Caught general '" << typeid(e).name() << "' exception:\n" << e.what() << std::endl;
error_exit(1);
} catch(std::string & e) {
std::cerr << "Caught a string thrown as an exception:\n" << e << std::endl;
Expand Down

3 comments on commit 2cf7858

@CelticMinstrel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a terrible idea for release builds, which are not compiled on MSVC.

@CelticMinstrel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The reason is that, unlike MSVC, GCC and clang do not demangle the typenames stored in the type_info class.)

@gfgtdf
Copy link
Contributor Author

@gfgtdf gfgtdf commented on 2cf7858 Jun 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't matter, these messages are mostly meant to be read by devs anyways.

Please sign in to comment.