LibAudio: Add LOADER_TRY to auto-convert Error to LoaderError
This commit is contained in:
parent
9702f2010f
commit
4f48a086b7
Notes:
sideshowbarker
2024-07-17 20:30:02 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/4f48a086b75 Pull-request: https://github.com/SerenityOS/serenity/pull/11344 Reviewed-by: https://github.com/alimpfard ✅ Reviewed-by: https://github.com/sin-ack
1 changed files with 9 additions and 0 deletions
|
@ -64,3 +64,12 @@ struct LoaderError {
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
// Convenience TRY-like macro to convert an Error to a LoaderError
|
||||
#define LOADER_TRY(expression) \
|
||||
({ \
|
||||
auto _temporary_result = (expression); \
|
||||
if (_temporary_result.is_error()) \
|
||||
return LoaderError(_temporary_result.release_error()); \
|
||||
_temporary_result.release_value(); \
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue