| 220 | */ |
| 221 | template<typename F> |
| 222 | bool WrapThrowableBool(F&& func) |
| 223 | { |
| 224 | try |
| 225 | { |
| 226 | if constexpr (std::is_same<typename std::invoke_result<F>::type, bool>::value) |
| 227 | { |
| 228 | return func(); |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | func(); |
| 233 | return true; |
| 234 | } |
| 235 | } |
| 236 | catch (const std::exception& e) |
| 237 | { |
| 238 | // TODO: How to handle this? |
| 239 | // g_lastExceptionMessage = e.what(); |
| 240 | LogError("%s", e.what()); |
| 241 | return false; |
| 242 | } |
| 243 | catch (...) |
| 244 | { |
| 245 | return false; |
| 246 | } |
| 247 | } |
| 248 | //endregion |
| 249 | } |