Exception not caught in try catch block

前端 未结 5 860
太阳男子
太阳男子 2021-01-13 13:20

I do a simple throw \"TEST THROW\" and it isn\'t caught in my catch (std::exception& e). Is it because I\'m catching an std::exception& e?

5条回答
  •  爱一瞬间的悲伤
    2021-01-13 13:49

    Since this is not a MCVE (what is Core?), I can't address explicitly the problem, but you are surely missing to

    #include 
    

    Actually, GCC compiles even without the inclusion, but exception won't be caught and you will end up with

    terminate called after throwing an instance of 'std::exception'

    what(): std::exception

    ./{program}: {PID} Aborted (core dumped)

提交回复
热议问题