Creating custom exceptions in C++

Your what() returns:

 return exception::what();

The return value from std::exception::what() is specified as follows:

Pointer to a null-terminated string with explanatory information.

That’s it. Nothing more, nothing else. The text you’re showing certainly qualifies as an “explanatory information”. And this is the only requirement for the return value of what() (except for one other one which is not germane here).

In other words, C++ does not guarantee the exact contents of what you get with what(). what() you see is what() you get, as the saying goes.

If you want your exception to describe itself, in some way, it’s up to you to implement that, as part of your what().

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)