update error_handling project CMake file

This commit is contained in:
Amar Mahmutbegovic
2024-07-03 18:54:04 +02:00
parent 463abf4a81
commit c505fd9c1a
3 changed files with 84 additions and 12 deletions

View File

@@ -1,7 +1,9 @@
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <csignal>
#include <exception>
#include <stdexcept>
#include <stm32f072xb.h>
@@ -39,11 +41,27 @@ int main()
std::array<int, 4> arr;
arr.at(5) = 6;
//arr.at(5) = 6;
printf("Exceptions example\r\n");
//throw 1;
try {
//throw 1;
arr.at(5) = 6;
}
catch (int i) {
printf("i = %d\r\n", i);
}
catch(std::out_of_range) {
printf("out of range\r\n");
}
catch (...) {
printf("Catch\r\n");
}
while(true)
{
}
}