here is my full code, I customize exception like:
class StdErr : public std::exception {
public:
str msg;
StdErr(str msg) { this->msg = msg; };
virtual const char *what() const override {
return this->msg.c_str();
};
};
and inherite it like:
class ShErr : public StdErr {
public:
ShErr(str m) : StdErr(m) { }
};
and use them like:
int main(int argc, char **argv) {
throw ro_err::ShErr("sh err");
return (0);
};
it raise looser throw specifier for ‘virtual const char* ro_err::StdErr::what() const’
, I have following questions:
Since c++11 what()
is noexcept. You have not declared it as noexcept. That is what the 'looser throw specifier' is telling you. See http://en.cppreference.com/w/cpp/error/exception/what.
I.e. declare it like
virtual const char *what() const noexcept override
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