C ++ exceptions are completely different from Java exceptions.
The C ++ standard states that the string returned by function () is completely arbitrary and is determined by the implementation:
virtual const char* what() const noexcept; Returns: An implementation-defined ntbs. Remarks: The message may be a null-terminated multibyte string (17.5.2.1.4.2), suitable for conversion and display as a wstring (21.3, 22.4.1.4). The return value remains valid until the exception object from which it is obtained is destroyed or a non-const member function of the exception object is called.
The return value, "std :: exception" is perfectly consistent with the C ++ standard.
Do not rely on C ++ exceptions to pinpoint where they were thrown from after you catch them, such as Java. This is beyond the scope of the C ++ standard. In C ++, an exception is nothing more than a mechanism for passing the execution control flow.
Having said that: many C ++ implementations will provide you with some implementation-specific mechanisms for dumping the current backtrace stack, at best from the runtime library. See the C ++ compiler documentation for more information.
gcc, for example, offers backtrace () along with some built-in gcc functions to convert raw addresses returned by backtrace () to characters, and other functions to demonstrate characters. Using this, you can come up with a crude counterpart to Java exception handling; although the gcc implementation is not perfect and has some functional holes, it also requires prior planning and custom exception classes, whose constructors fix the current stack stack (before the exception is actually thrown); and, once caught, an instance of the excluded exception class can be checked for captured return information.
But that doesnβt really help your current situation. I would suggest that you check your C ++ compiler documentation, as I suggested, and also explore the capabilities of your debugger. The C ++ debugger should allow you to set a breakpoint when all exceptions are thrown, and before they are caught so that you can check the stack backtrack through the debugger when an exception occurs.
Sam varshavchik
source share