一、错误代码
在使用odb-orm库的时候,编写一个object类,为了防止插入异常值引发问题,做了一些自定义参数类型检查,自定义抛出exception。
void nameType(int nameType)
{
if (checkNameType(nameType)){
nameType_ = nameType;
modifiedTime_ = currentDateTime();
} else {
throw std::exception("The enum value range out of all values!");
}
}
使用msvc2019x64,c++17编译的时候,报了如标题的错误。
二、解决方案
大概的意思,exception不能准确捕获到问题,编译限制,希望你更具体的抛出问题。
#include <stdexcept>
throw std::logic_error("XXX");
三、参考资料