asynchrony 0.0.0
Add asynchrony to your C++ applications using standard C++20
Loading...
Searching...
No Matches
common.hpp
1#pragma once
2#ifndef ASYNCHRONY_COMMON_HPP
3#define ASYNCHRONY_COMMON_HPP
4
5#include <exception>
6
7
8namespace siddiqsoft
9{
15 static bool isCriticalException(const std::exception_ptr& ep)
16 {
17 if (!ep) return false;
18
19 try {
20 std::rethrow_exception(ep);
21 }
22 catch (const std::bad_alloc&) {
23 // Memory allocation failure - critical
24 return true;
25 }
26 catch (const std::bad_exception&) {
27 // Bad exception - critical
28 return true;
29 }
30 catch (const std::bad_cast&) {
31 // Bad cast - critical
32 return true;
33 }
34 catch (const std::bad_typeid&) {
35 // Bad typeid - critical
36 return true;
37 }
38 catch (const std::exception&) {
39 // Regular exception - not critical
40 return false;
41 }
42 catch (...) {
43 // Unknown exception - treat as critical
44 return true;
45 }
46 }
47} // namespace siddiqsoft
48
49#endif // !ASYNCHRONY_COMMON_HPP