草庐IT

catch-exception

全部标签

c++ - 是否所有官方 Qt 二进制文件都使用 -no-exceptions 构建?

如果我写try{throwstd::exception("Exception");}catch(std::exception&ex){qDebug("GameOver");}在我的主函数(或其他任何地方)中,我的Qt应用程序崩溃了。Exceptionhandlingdoesn'tworkwithQtonWindows中描述了这种效果(5年前).原来的发布者显然通过自己重新配置和重建QtSDK(显式启用-exceptions)解决了这个问题,但我很难相信所有Qt二进制文件都关闭了异常并且每个使用异常的人都必须这样做。谁能告诉我这是记录在案的地方,告诉我这是真的还是我在这里做错了什么?我现

【错误解决】requests.exceptions.SSLError:wrong version number (_ssl.c:1131)

错误解决:requests.exceptions.SSLError:wrongversionnumber(_ssl.c:1131)requests.exceptions.SSLError:HTTPSConnectionPool(host=‘192.168.79.128’,port=8080):Maxretriesexceededwithurl:/admin/login(CausedbySSLError(SSLError(1,‘[SSL:WRONG_VERSION_NUMBER]wrongversionnumber(_ssl.c:1131)’)))尝试1:进入电脑的“网络和Internet“设置

c++ - 让 Visual Studio 中断用户(std::exception)异常?

我的代码抛出未处理的异常,但VisualStudio中的调试器只中断系统抛出的异常。例如,getaddrinfo的返回值不为零,我的异常应该首先抛出-事实上,如果我在第171行放置一个断点,它会被命中-但调试器只在调用socket时中断。我知道Ihavetoaddmyowntypesexplicitly,orelsecheckAllC++Exceptionsnotinthislist,在ExceptionSettings中,但这是我抛出的std::exception,而std::exception是检查过。如何让VisualStudio调试器在出现异常时自动中断?

c++ - 为什么这段代码会出现 "exception spec is more lax than base"错误?

尝试使用Xcode6.1中的clang版本(基于LLVM3.5svn的clang-600.0.54)编译以下代码,使用-std=c++11和-stdlib=libc++给我一些我不太明白的错误。#includestructImpl{typedefstd::functionL;Ll;inti;};structHndl{Impl*impl;Hndl(Impl*i):impl(i){}~Hndl()noexcept(false){}};intmain(intargc,char*argv[]){Hndlh(newImpl());h.impl->l=[=]{h.impl->i=42;};retu

c++ - Try-catch 在共享库中不起作用?

(这类似于myotherquestion但这是另一回事,即使它是相关的)我的项目中遇到了一个大问题。我有一个处理XML并可以抛出异常的库。并且,使用它来创建配置文件类显示了我的第一个错误:库中根本没有处理异常,每个异常都没有处理。在我写的库中:try{throwstd::exception();}catch(...){printf("caught\n");}但是,异常没有被处理并立即调用std::terminate:terminatecalledafterthrowinganinstanceof'std::exception'what():std::exception编译标志是最简单的

c++ - 在现代 C++ 中使用 try..catch block 通过模板元编程包装任意函数调用

我想创建一些模板,基本上应该包装它的参数。参数应该是一个任意的函数调用,它通过一些带有前缀和后缀代码的模板元编程魔法被包装。我想像下面这样使用它:autoresult=try_call(some_vector.at(13));和try_call将以某种方式定义,它将try..catchblock包装在some_vector.at(13)周围。像这样:template//sometemplatemetaprogrammingmagicheretry{autovalue=//executetheparameterhere,i.e.some_vector.at(13);returnstd::

c++ - 我可以修改 std::exception_ptr 中异常的值吗?

如果我在std::exception_ptr中存储了一个异常。我使用std::rethrow_exception重新抛出异常,使用catch(MyException&)访问它,然后修改值。如果我再次抛出相同的异常,我是否应该观察我所做的修改?下面的代码展示了我的想法:#include#includestructMyException{intvalue;};intmain(){std::exception_ptra=std::make_exception_ptr(MyException());try{std::rethrow_exception(a);}catch(MyException

c++ - 如何将 CMake 与 Catch2 一起使用?

来自Catch2'sexample,我试着用cmake运行这个例子,我的项目结构是这样的:/factorial+--CMakeLists.txt+--/bin+--/include|+--catch.hpp|+--fact.hpp+--/src|+--CMakeLists.txt|+--fact.cpp+--/test+--CMakeLists.txt+--test_fact.cppfact.cpp:unsignedintfactorial(unsignedintnumber){returnnumberfact.hpp:#ifndefFACT_H#defineFACT_Hunsigne

c++ - LoadLibrary 失败 : First chance exception 0xC0000139 (DLL Not Found) - How to debug?

我有一个dll“mytest.dll”,当通过LoadLibrary()加载时,返回NULL(并且127作为GetLastError())。如果我在“mytest.dll”上使用DependencyWalker,它会报告它应该正确加载并且正确找到所有DLL。在主机exe上运行DependencyWalker的探查器选项会在日志中显示以下相关部分:00:00:55.099:Loaded"mytest.DLL"ataddress0x07860000bythread0xBBC.Successfullyhookedmodule.00:00:55.115:Firstchanceexception

c++ - 影响和异常(exception)

假设我有以下功能:SomeTypecreateSomeType();根据某些原因可以抛出。然后:SomeTypeval=SomeType();//initialvaluetry{val=createSomeType();//here}catch(std::exception&){}如果createSomeType()抛出异常,我是否可以始终假设val值未更改? 最佳答案 是的,如果createSomeType()抛出异常,赋值将不会发生。控制流将从throw语句开始,通过createSomeType()在堆栈上拥有的任何对象的析构函