You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Logging C++ exceptions inside try/catch block #1229
Basically it's working, but I'm not sure if I'm collecting all types of exceptions?
In short: no.
Also related to your other question: a C++ catch will only receive C++ exceptions, not allSEH exceptions. If you want to handle SEH exceptions, which includes hard faults like memory access errors and C++ exceptions, you need to use the SEH primitives.
You will only catch exceptions in the type hierarchy of std::exception, thus guaranteeing a what() interface. In C++, you can throw almost anything (besides incomplete or abstract types), so even if you only consider catching C++ exceptions, you will ignore all that aren't a std::exception.
for instance the following is not captured as std::execption and falls through the default catch (...) handler:
Yes, a NULL-pointer dereference does not result in a C++ exception, and such a catch will be bypassed. While C++ exceptions are implemented in terms of SEH exceptions on Windows, SEH exceptions are a superset. If you want to handle all SEH exceptions, use the SEH primitives (__try, __except, __finally). However, these are at a much lower level (you'd have to manually filter the incoming SEH exception to identify it as a C++ exception) and have different semantics. Of course, these handlers are not portable to other platforms.
Activity
supervacuus commentedon May 8, 2025
In short: no.
catchwill only receive C++ exceptions, not allSEHexceptions. If you want to handleSEHexceptions, which includes hard faults like memory access errors and C++ exceptions, you need to use the SEH primitives.std::exception, thus guaranteeing awhat()interface. In C++, you can throw almost anything (besides incomplete or abstract types), so even if you only consider catching C++ exceptions, you will ignore all that aren't astd::exception.Yes, a
NULL-pointer dereference does not result in a C++ exception, and such acatchwill be bypassed. While C++ exceptions are implemented in terms ofSEHexceptions on Windows,SEHexceptions are a superset. If you want to handle allSEHexceptions, use theSEHprimitives (__try,__except,__finally). However, these are at a much lower level (you'd have to manually filter the incomingSEHexception to identify it as a C++ exception) and have different semantics. Of course, these handlers are not portable to other platforms.