From 3ca114e0f6495b817805f6935089490e3f16b4e1 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Sat, 30 Mar 2024 13:05:15 +0100 Subject: [PATCH] C++ exceptions test --- clionenv.sh | 7 +++++++ src/test/hello2.cpp | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 clionenv.sh diff --git a/clionenv.sh b/clionenv.sh new file mode 100644 index 000000000..bd5f2920d --- /dev/null +++ b/clionenv.sh @@ -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" + diff --git a/src/test/hello2.cpp b/src/test/hello2.cpp index a6e8fad6d..c17703fa5 100644 --- a/src/test/hello2.cpp +++ b/src/test/hello2.cpp @@ -1,5 +1,18 @@ #include +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; } \ No newline at end of file