Add RETURN_IF_EXCEPTION macro for improved error handling
This commit is contained in:
@@ -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()); \
|
||||
|
||||
Reference in New Issue
Block a user