diff options
author | kleines Filmröllchen <filmroellchen@serenityos.org> | 2022-01-14 01:14:24 +0100 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-01-22 01:13:42 +0330 |
commit | 4f48a086b75721f246fa496bcfc07bd2b45bae0a (patch) | |
tree | 69931feece254193d6a66fd89e125dea4f4eb3cb /Userland/Libraries/LibAudio/LoaderError.h | |
parent | 9702f2010fc1d0760f8267fa1016cdf131e32532 (diff) | |
download | serenity-4f48a086b75721f246fa496bcfc07bd2b45bae0a.zip |
LibAudio: Add LOADER_TRY to auto-convert Error to LoaderError
Diffstat (limited to 'Userland/Libraries/LibAudio/LoaderError.h')
-rw-r--r-- | Userland/Libraries/LibAudio/LoaderError.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibAudio/LoaderError.h b/Userland/Libraries/LibAudio/LoaderError.h index cc630fcdb8..583476c032 100644 --- a/Userland/Libraries/LibAudio/LoaderError.h +++ b/Userland/Libraries/LibAudio/LoaderError.h @@ -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(); \ + }) |