C++ exceptions test

This commit is contained in:
2024-03-30 13:05:15 +01:00
parent 90950e89d6
commit 3ca114e0f6
2 changed files with 21 additions and 1 deletions

7
clionenv.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
# FIXME:
export PREFIX="/Users/stepus53/projects/os2/toolchain/gcc-x86_64-os3-prefix/"
export TARGET=x86_64-os3
export PATH="$PREFIX/bin:$PATH"

View File

@@ -1,5 +1,18 @@
#include <iostream>
void badfn() {
throw std::runtime_error("oops");
}
int main() {
std::cout << "Hi!" << std::endl;
std::cout << "hi" << std::endl;
try {
std::cout << "try" << std::endl;
badfn();
std::cout << "ok" << std::endl;
} catch (std::exception &e) {
std::cout << "huh" << std::endl;
std::cout << e.what() << std::endl;
}
std::cout << "fin" << std::endl;
}