为什么CLion没有显示异常?

时间:2020-05-29 09:46:13

标签: c++ cmake cygwin clion jetbrains-ide

CLion在运行代码时似乎没有向我显示任何异常。为了对此进行测试,我仅使用以下代码创建了一个新项目:

#include <iostream>

int main() {
    std::cout << "--- One" << std::endl;
    throw 6;
    std::cout << "--- Two" << std::endl;
    return 0;
}

这将导致以下输出:

C:\Users\david\CLionProjects\untitled\cmake-build-debug\untitled.exe
--- One

Process finished with exit code 0

如您所见,执行异常之前的代码,执行异常之后的代码(正如您所期望的那样)。但是,它没有显示有关异常的消息,而是显示“进程以退出代码0完成”,好像没有发生异常。

在Ubuntu(通过终端)上编译和执行的相同代码显示错误消息。所以我认为问题出在CLion。

如何解决此问题,以便可以在代码中看到异常消息?

是否存在任何可能导致这种行为的设置?

我在Windows 10和Cygwin上使用CLion。这是问题的屏幕截图:

Here's a screenshot of the problem

1 个答案:

答案 0 :(得分:0)

投掷还需要尝试捕捉

发件人: http://www.cplusplus.com/doc/tutorial/exceptions/

        <Grid item xs={12} md={6} className={classes.heroGrid}>
          <Typography variant='h3' >
Some stuff
          </Typography>
          <div style={{ display: 'flex' }}>
            here
          </div>

        </Grid>
在cygwin下编译并运行的

显示:

    heroGrid: {
      flexDirection: 'column',
      justifyContent: 'space-between',
      alignContent: 'space-between',
      alignItems: 'space-between'
    }