If I just want to throw a string, isn't there a built in type somewhere so that I can just do
throw standard_exception("This is wrong!");
Or do I have to define such a standard exception that derives from exception myself? I know it is very simple to do so, I just thought this would be so common that it would be defined somewhere.
Thanks
std::runtime_error and std::logic_error (both derived from std::exception) both have constructors that take strings and override the what() member function to return the provided string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With