summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkleines Filmröllchen <filmroellchen@serenityos.org>2022-01-14 01:14:24 +0100
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-01-22 01:13:42 +0330
commit4f48a086b75721f246fa496bcfc07bd2b45bae0a (patch)
tree69931feece254193d6a66fd89e125dea4f4eb3cb
parent9702f2010fc1d0760f8267fa1016cdf131e32532 (diff)
downloadserenity-4f48a086b75721f246fa496bcfc07bd2b45bae0a.zip
LibAudio: Add LOADER_TRY to auto-convert Error to LoaderError
-rw-r--r--Userland/Libraries/LibAudio/LoaderError.h9
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(); \
+ })