草庐IT

throw_exception

全部标签

php - 未捕获的 MongoDB\Driver\Exception\ConnectionException : $or must be an array - PHP

我正在尝试使用MongoDB'sPHPdriver的$or运算符进行查询,但我收到以下错误:Fatalerror:UncaughtMongoDB\Driver\Exception\ConnectionException:$ormustbeanarrayin/path/to/file.php:83Stacktrace:#0/path/to/file.php(83):MongoDB\Driver\Manager->executeQuery('userAccou...',Object(MongoDB\Driver\Query))#1{main}thrownin/path/to/file.ph

php - 未捕获的 MongoDB\Driver\Exception\ConnectionException : $or must be an array - PHP

我正在尝试使用MongoDB'sPHPdriver的$or运算符进行查询,但我收到以下错误:Fatalerror:UncaughtMongoDB\Driver\Exception\ConnectionException:$ormustbeanarrayin/path/to/file.php:83Stacktrace:#0/path/to/file.php(83):MongoDB\Driver\Manager->executeQuery('userAccou...',Object(MongoDB\Driver\Query))#1{main}thrownin/path/to/file.ph

c++ - 我可以复制构造带有错误信息的 boost::exception 吗?

考虑以下使用boost异常类的代码:classexception:virtualpublicboost::exception{//...};templateclassexception_impl:virtualpublicstd::exception,publicExc{public:exception_impl(constExc&exc):Exc(exc){}virtualconstchar*what()constthrow(){return"blah";}};(实际上这段代码更复杂。例如,exception_impl仅从std::exception派生,如果后者还不是直接或间接基类

c++ - 如果 throw 会发生什么;语句在 catch block 之外执行?

在C++中,throw;在catchblock内执行时会将当前捕获的异常重新抛出block外。在thisanswer当经常使用复杂的异常处理时,异常调度器的想法被提出来作为减少代码重复的解决方案:try{CodeThatMightThrow();}catch(...){ExceptionHandler();}voidExceptionHandler(){try{throw;}catch(FileException*e){//dohandlingwithsomecomplexlogicdeletee;}catch(GenericException*e){//dohandlingwitho

c++ - std::throw_with_nested 需要 C++11 中的多态类型?

为什么这不能编译(用Clang3.4.2和GCC版本4.7.4、4.8.3和4.9.1试过):#includestructE{E(int){}};intmain(){std::throw_with_nested(E(42));return0;}来自GCC4.9.1的错误:Infileincludedfrom/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.1/include/g++-v4/exception:163:0,fromtest.cpp:1:/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.1/include/g++-v4/bit

c++ - 当抛出异常的代码链接到使用 -fno-exceptions 编译的库时会发生什么?

具体来说,我想知道GCC对抛出异常的代码在链接到使用-fno-exceptions编译的代码时的行为做出了哪些保证(如果有的话)。GNUlibstdc++手册说以下here。Beforedetailingthelibrarysupportfor-fno-exceptions,firstapassingnoteonthethingslostwhenthisflagisused:itwillbreakexceptionstryingtopassthroughcodecompiledwith-fno-exceptionswhetherornotthatcodehasanytryorcatch

c++ - throw() (即 __declspec(nothrow)) 是否在 Visual C++ 中提供了真正的好处?

专注于VisualC++,您是否体验过使用throw()(即__declspec(nothrow))非抛出规范在C++代码中的显着性能提升?它真的对优化器有帮助吗?是否有任何基准显示性能提升?我在网上找到了不同的(相反的)建议:Boostexception-specificationrationale反对throw(),而LarryOsterman在他的博文中似乎赞成:Whyaddathrow()toyourmethods?(我想澄清一下,我对VC++特定的代码感兴趣;我知道在GCC中,throw()规范实际上可以是一种“悲观化”"由于运行时检查。)P.S.阅读ATLheaders,发

c++ - SWIG 包装库中 __cxa_allocate_exception 期间的段错误

在为Ruby开发一个SWIG封装的C++库时,我们在C++代码内的异常处理过程中遇到了无法解释的崩溃。我不确定重新创建问题的具体情况,但它首先发生在调用std::uncaught_exception期间,然后在一些代码更改后,移至__cxa_allocate_exception在异常构造期间。GDB和valgrind都没有提供任何有关崩溃原因的见解。我找到了几个类似问题的引用资料,包括:http://wiki.fifengine.de/Segfault_in_cxa_allocate_exceptionhttp://forums.fifengine.de/index.php?topic

c++ - Googletest 不接受 EXPECT_THROW 中的临时对象

我有一个没有默认构造函数的类,但构造函数可能会抛出。我想要一个像这样的测试:EXPECT_THROW(MyClass(param),std::runtime_error);但是编译器g++提示MyClass没有默认构造函数。但是,以下...EXPECT_THROW(MyClassfoo(param),std::runtime_error);...工作,并且测试按预期通过。为什么Googletest不接受临时对象?classMyClass{public:MyClass(std::stringconst&filename);//...};有趣的是,我重构了我的测试,使文件名不在单独的变量中

c++ - 这个头文件是什么意思(virtual const char* what() const throw())?

classmyexception:publicexception{virtualconstchar*what()constthrow(){return"Myexceptionhappened";}};抱歉,这个问题可能听起来很愚蠢,但我无法解析标题。有人可以用英语描述标题的实际含义吗?首先让我觉得奇怪的是关键字virtual。myexception类不是基类,它继承自已经实现的exception类,那么为什么在这里使用virtual呢?我猜const是用于返回类型,它是一个c风格的字符串,它是const,而另一个const是为了确保这个对象不能被修改(有人能告诉我那个物体可能是什么吗?