Add RETURN_IF_EXCEPTION macro for improved error handling

This commit is contained in:
scawful
2025-01-21 21:54:10 -05:00
parent 04c083bdfe
commit 1764ca0dde

View File

@@ -109,6 +109,14 @@
return temp; \
}
#define RETURN_IF_EXCEPTION(expression) \
try { \
expression; \
} catch (const std::exception &e) { \
std::cerr << e.what() << std::endl; \
return EXIT_FAILURE; \
}
#define SDL_RETURN_IF_ERROR() \
if (SDL_GetError() != nullptr) { \
return absl::InternalError(SDL_GetError()); \